3 ms·
Prototypal inheritance plays a huge role in understanding the language because JavaScript uses it for everything. It might be a good idea to learn about this b
by thinkxl 9y ago
Prototypal inheritance plays a huge role in understanding the language because JavaScript uses it for everything.
It might be a good idea to learn about this before using ES6 classes; remember that ES6 classes are syntactic sugar on top of prototypal inheritance anyway. They wouldn't learn legacy patterns, but the actual pattern that JavaScript uses.
- chrismeller 9y agoI grant you that it plays (or at least played) a huge part, but as things move towards ES6 classes (which are very similar to every other language with classes), I would still argue that you’re insisting upon learning prototype inheritance for no real reason.
- thinkxl 9y agoYou are missing the point; if you use JavaScript, you use prototypal inheritance whether you like it or not, e.g.: function getUser() {} That is creating an instance of the `Function` constructor object[1][2]. In a Classical (as classes) language, you would see that like this: // `Function` being a class function getUser extends Function {} but because JavaScript is purely prototypal, this works differently. You say that there's no reason to learn prototypal inheritance, well, the only and valid reason is that to write at least decent JavaScript you have to understand how it works behind the scenes. * [1] - https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Function https://developer.mozilla.org/en-US/docs/Web/JavaScript/Refe... * [2] - https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects https://developer.mozilla.org/en-US/docs/Web/JavaScript/Refe... Edit: add links