DEV Community

Discussion on: Implement JavaScript Array Methods From Scratch

Collapse
 
mindplay profile image
Rasmus Schultz

Extending prototypes isn't generally a good idea - plenty of answers in this SO question covering why:

stackoverflow.com/questions/140341...

There is no particular reason to do so in JavaScript in the first place - given that "methods" are really just inherited properties containing functions, and there is no functional difference. It's purely syntax and the implicit this, which is often better explained and easier to use when given explicitly as a proper named argument.

Really, the only time you should extend prototypes is in polyfills.

Learning how to do it is fine, of course, but should come with the disclaimer that most people shouldn't and don't need to do it. 🙂

Collapse
 
zagaris profile image
Aris Zagakos

Hi Rasmus, i agree with you. Actually, i have a disclaimer and i say that it doesn't intend to replace the existing methods. I used these examples for learning purposes only.