1. getPrototypeOf reads [[Prototype]]
Object.getPrototypeOf returns an object's internal [[Prototype]] link, here Array.prototype.
Object.getPrototypeOf(arr) === Array.prototype // trueTyporithm · medium
Step 1 of 8 · intro card
Prototypes & Classes
Every object has an internal [[Prototype]] link, read via Object.getPrototypeOf or __proto__. Property reads walk up this chain until found or null. A constructor's .prototype becomes the [[Prototype]] of instances made with new — so .prototype lives on functions while __proto__ lives on instances.
Every JavaScript object has a hidden [[Prototype]] reference to another object (or null). You read it with Object.getPrototypeOf(obj) or the legacy obj.__proto__, and both return the same link.
When you read obj.prop, the engine looks on obj itself, then walks up the prototype chain — obj's [[Prototype]], then that object's [[Prototype]], and so on — until the property is found or the chain reaches null and you get undefined.
A constructor function carries a .prototype object, and new Ctor() creates an instance whose [[Prototype]] is set to Ctor.prototype. That is the key distinction: .prototype is a property of functions, while __proto__ is the per-instance link to it.
Object.getPrototypeOf / __proto__ read the [[Prototype]] link.
Reads walk the chain until found or null.
.prototype is on functions; __proto__ is on instances.
const arr = [1, 2, 3]
Object.getPrototypeOf(arr) === Array.prototype // true
arr.__proto__ === Array.prototype // true — same thing
function Dog(name) { this.name = name }
Dog.prototype.bark = () => "woof"
const d = new Dog("Rex")
Object.getPrototypeOf(d) === Dog.prototype // trueConnect each part of the code to the concept before you type.
Object.getPrototypeOf returns an object's internal [[Prototype]] link, here Array.prototype.
Object.getPrototypeOf(arr) === Array.prototype // true__proto__ is the legacy accessor for the same [[Prototype]] that getPrototypeOf returns.
arr.__proto__ === Array.prototype // true — same thingA constructor function's .prototype object holds methods shared by every instance.
Dog.prototype.bark = () => "woof"new creates an object whose [[Prototype]] is set to Dog.prototype.
const d = new Dog("Rex")The new instance's [[Prototype]] is exactly the constructor's .prototype object.
Object.getPrototypeOf(d) === Dog.prototype // trueRead the concept map and follow the code breakdown.
Type the implementation, repair mistakes and work through every recall exercise.
Use the final check without hints; revisit weak concepts in short practice sessions.