This is a referenced module from douglas crockford's Javascript The good part.
Douglas said that objects are passed by reference and are never copied.
In the example below, a module is assigned.
Even though a module is an object, the same result as Object.create is coming out.
Douglas uses it like this:
var david = edge();
Why is a new object being allocated even though I don't use the create function?
If I have to create multiple objects based on edges (I'm making them now and I'm using them without problems), is there any problem?
Wouldn't it be better to use Object.create when creating multiple objects?
What I have tried:
edge = function(a, b){
const name = a;
const age = b;
const html = name+" "+age;
return {
display:function(){
return html;
}
}
}
let david = edge('david', '23');
david.display();
let tom = Object.create(edge('tom', '52'));
tom.display();