Difference between Object.key and Object.prototype.key

suggest change

Unlike in languages such as Python, static properties of the constructor function are not inherited by instances. Instances inherit from the constructor’s prototype, which inherits from the parent prototype. Properties set on the constructor itself stay there.

function Foo() {};
Foo.style = 'bold';

const foo = new Foo();

console.log(Foo.style); // 'bold'
console.log(foo.style); // undefined

Foo.prototype.style = 'italic';

console.log(Foo.style); // 'bold'
console.log(foo.style); // 'italic'

Feedback about page:

Feedback:
Optional: your email if you want me to get back to you:



Table Of Contents