Reflection and Extend
Reflection: An object can look at itslef, listen and change its properties and method
var john = {
firstname: 'John',
lastname: 'Doe'
}
john._proto_ = person;
for(var prop in john); {
console.log(prop + ": " + john[prop]);
}
What we get on chrome console:
firstname: John
lastname: Doe
getFullName: function(){
return this.firstname + this.lastname;
}
if(john.hasOwnProperty('prop'))
Eg 2:
var jane = {
address = '111 Main St',
getFormalFullName: function(){
return this.lastname + ',' + this.firstname
}
}
var jim = {
getFirstName: function(){
return firstname;
}
}
_.extend(john, jane, jim);