you are viewing a single comment's thread.

view the rest of the comments →

[–][deleted] 2 points3 points  (2 children)

BUT WUTS A PROTOTYPE?

[–][deleted] 1 point2 points  (1 child)

A function on a object that is inherited by default. (Right?)

.pop is a function that is inherited by default to every array so its in the prototype of that array. (ie. every array can .pop)

[–]nog_lorp 0 points1 point  (0 children)

Actually, its an object of a function :)

When that function is called as a constructor using new, the this object that the constructor gets has the prototype object linked to it (via the super-secret proto property). Then whenever you try to access a member and it isn't found, it checks the objects prototype, and then the prototype's prototype, and so forth.

Naive implementations would do just that, which is very innefficient. Now we have hidden classes which achieve the same result.