JavaScript Object.create() Explained

JavaScript Logo

Object.create() – Creates a new object with the specified prototype object. Useful for inheritance.

๐Ÿ‘‰ Syntax

const newObj = Object.create(proto);

๐Ÿงช Example

const animal = { eats: true };
const rabbit = Object.create(animal);
console.log(rabbit.eats);

Comments