Prototype is awsome

You guys didn’t cover the prototype thing on the fcc.
Today i learned to build methods to work on arrays and objects using the expression Array.prototype.something…
I always thought about who makes methods in js and how they do it.
I felt good creating something that is usualy given with the language :slight_smile: .
And by chance i learned how to add a property to a constructor function using the keyword prototype.
Fcc really gives you the push though.
I’m addicted to codewars now.
Happy coding.

I think a lot, if not most developers would caution against adding methods to the Object class (which is what an Array is). Rather, I think you should probably create your own array class derived from Array and then you can go crazy adding any methods you want.


In the “JavaScript Algorithms an Data Structures” course there is a section called " Object Oriented Programming" which covers prototypical inheritance. I believe that starts somewhere around the lesson Use Prototype Properties to Reduce Duplicate Code

I’m close to there, just having to revise everything i learned so far every other week, and work.

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.