Simon Morgan

Another programming blog

JavaScript Prototypes for the Confused

Objects can have a prototype and a prototype is just another object. We can get an object’s prototype using the Object.getPrototypeOf method. Object.getPrototypeOf({}); // → {} Yes, JavaScript really loves objects. It’s objects all the way down. Actually that’s not completely true: Object.getPrototypeOf(Object.getPrototypeOf({})); // → null The first call to Object.getPrototypeOf gave us the prototypical object—the one that acts as the prototype for practically all objects—and calling Object.

JavaScript Properties for the Confused

Like a lot of things related to JavaScript, the syntax and semantics of properties can be a little tricky to wrap your head around. Hopefully this article will serve to simplify and clarify things. Our first step is to do away with the idea of arrays. But wait, arrays are important, surely? Yes, but they’re just conceptual baggage when it comes to understanding properties because arrays are also objects. And don’t call me Shirley.