I am going some deep into javascript object operations.
Here my question is what is a different between const me = Object.create(person); and const me = person; here both operation gives me a slimier output. I mean it references object to new variable me.
const person = {
isHuman: false,
printIntroduction: function() {
console.log(`My name is ${this.name}. Am I human? ${this.isHuman}`);
}
};
const me = Object.create(person);
me.name = 'Matthew';
me.isHuman = true;
me.printIntroduction();
const me2 = person;
me.name = 'Manan';
me.isHuman = false;
me.printIntroduction();
In above code I have included both operation direct assignment and assign by using Object.create();. Here both variable referencing to objects person, but what is different between it? Can some one explain me?
This question might be asked before but I cant find proper explanation. Simple explanation would be appreciated :-).