3 ms·
> Believe it or not, it is the most commonly used form of inheritance in JavaScript. Are extend, assign etc really more common than just working with prototype
by Kiro 11y ago
> Believe it or not, it is the most commonly used form of inheritance in JavaScript.
Are extend, assign etc really more common than just working with prototypes? I've personally never used it but written a lot of OO code using prototype delegation.
- pluma 11y agoI'm not sure it makes sense to rank these two in terms of popularity as they're generally used for very different things. Delegation is heavily used in combination with constructors (both ES6 classes and traditional) and factories. Extension is typically used to apply default values, merge data objects or update multiple properties at once. The use of extension in a way that could reasonably be called a "form of inheritance" is mostly limited to mixins, which I would say aren't more popular than using prototypes (at least not obviously so).