Skip to content

OutputNot attempted

Walking the chain

class X {}
const x = new X();
console.log(
Object.getPrototypeOf(x) === X.prototype,
Object.getPrototypeOf(X.prototype) === Object.prototype,
Object.getPrototypeOf(Object.prototype),
X.prototype.constructor === X,
typeof X,
);

Spaces and quote style don’t matter · write a thrown error as TypeError

Ctrl Enter
Show answer & explanation

The expected output comes from actually running the snippet; opening this shows it next to the explanation.

x → X.prototype → Object.prototype → null. Every prototype has a constructor pointing back. A class is just a function.