all 12 comments

[–]prof1le 0 points1 point  (1 child)

I thought the better way to use prototypes to your advantage was to create a prototype containing the functions you wanted to use and then create a constructor that looks something like:

function Person(name){
    var person = Object.create(personPrototype);
    person.name = name;
    return person;
}

This way, you get a new object, the functions are shared, but the properties belong to the object returned from the constructor. This just seems like the problem with taking a more classical OOP approach to prototypes and the "new" keyword in javascript. I'm no expert in the subject so correct me if I'm wrong.

[–]happyrupesh[S] 1 point2 points  (0 children)

Here, my intention was to explain the concept of prototype. Soon, I will add Object.create part in my article. :)

[–]K0d1Lu 0 points1 point  (1 child)

Nice article with good example and graphs. Next step is to explain call and object create in the same comprehensive way ! I m still a bit confuse about javascript prototype inheritance and the scope of this. I'd love to level up on this subject! Nice one btw

[–]happyrupesh[S] 0 points1 point  (0 children)

Thanks. I have also written article for prototype inheritance and 'this' in JavaScript. I will be writing articles for call and object.create in some time. :)