You dont know js prototypal inheritance

broken image

Prototype inheritance is the same thing as classical inheritance. Classical inheritance uses prototype chaining or inheritance. Prototypal inheritance is a form of delegation. Prototype chaining means copying of properties & behaviour. Not everyone might agree which the author's suggestions about the best way to go about writing JavaScript code, but it definitely gives food for thought and it's certainly worth the outlay (especially if, like me, you are coming to JavaScript from a fully object-oriented language like C#) and I'll be purchasing others in the series too. Classical Inheritance is where properties and behaviour are inherited from some map / blueprint. ) including an appendix which is useful warning about how the new ECMA 6 class syntax obscures what is happening, being syntactic sugar and in fact nothing to do with classes at all and still using prototypal inheritance under the hood, and could actually cause more problems than it might solve. It also includes mention of forthcoming ECMA 6 features (though full discussion of these will be left to a forthcoming publication It could have been a considerably briefer work, and combined with other volumes in the series. Kyle Simpson's explanations of the behaviour of 'this' and of prototypal inheritance in JavaScript are the best I've seen, albeit a bit belaboured and verbose at times, including a very lengthy diversion on 'how not to do it' by trying to coerce a kind of pseudo-class-based inheritance upon the language.