Understanding the Difference Between Object.create and New Operator
source link: https://hackernoon.com/understanding-the-difference-between-objectcreate-and-new-operator-vfr37ab
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
@vaibhavsilarVaibhav Silar
writing simple code is most challenging task
Most of us must have seen object creation using two methods, Object.create and new operator). But some of you must have wondered what the difference is between the two methods. Let's dive into the them and outline the differences.
Consider the below code snippet.
function Animal()
{
this.name = null;
}
Animal.prototype.getName = function()
{
return this.name;
}
Recommend
About Joyk
Aggregate valuable and interesting links.
Joyk means Joy of geeK