A method is a property whose value is a function intended to provide behavior associated with an object. Property lookup finds it directly or through the prototype chain. section 5.3.2
Finding a method and deciding what it operates on are separate steps. JavaScript determines this at runtime from how the function is created and called, allowing one method to serve different objects. section 5.4
Shared prototype behavior
const drawerPrototype = { open() {} }; const drawer = Object.create(drawerPrototype); drawer.open(); The open method is stored on the prototype, found through lookup, and invoked as behavior associated with drawer. section 5.3.2 section 5.4
const drawerPrototype = { open() {} };
const drawer = Object.create(drawerPrototype);
console.log(Object.getPrototypeOf(drawer) === drawerPrototype); #A
console.log(Object.getPrototypeOf(drawerPrototype) ===
Object.prototype); #A
console.log(Object.getPrototypeOf(Object.prototype) === null); #ATrace the prototype links that make a method available on an object without being stored directly on it. section 5.3.2
























