I'm trying to understand the prototypical chain in JavaScript. What I think to know so far (please correct me where I'm wrong):
(Almost) everything in JavaScript is an object. Arrays are also objects, therefore they inherit certain properties, like methods, from the parent. So every array or object I create is actually a child of the object class.
BUT: If I create a new array and try to tap into the properties by doing
console.log(myArray.prototype)
I get undefined. And if I try
console.log('3', Array.prototype);
I get an empty array. Now I have a few questions:
- Can someone explain to me why I can't seem to tap into it?
- It seems like every array-method-documentation specifies Array.prototype.map() and I don't understand why we have to point it out like that
- Why exactly did the class based approach get rid of the prototype keyword (even though the functionality behind it seems to be the same still)
Thank you guys!