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. 🙂
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.
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
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. 🙂
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.