bhylu.com

Advertisements

Object Study Path

Objects can define behaviour as well as store data. Start by understanding own properties before following a prototype chain.

Where to run this

This example uses the JavaScript console playground. Select Run to execute it; the example does not run on this lesson page.

A practical example

JavaScript

const session = Object.create({kind: "workshop"});
session.title = "Repair club";
console.log(Object.keys(session));
console.log(session.kind);

What happens

Only title is an own enumerable key; kind comes from the prototype.