UNPKG

planetproto

Version:

A Workshop for understanding JavaScript prototypes

28 lines (20 loc) 450 B
var machine = { motors: null }; var vehicle = {}; var robot = {}; // -> Let's make machine the prototype of robot and vehicle vehicle.__proto__ = machine; robot.__proto__ = machine; claim(machine.motors, null); claim(robot.motors, null); claim(vehicle.motors, null); robot.motors = 4; claim(machine.motors, null); claim(robot.motors, 4); claim(vehicle.motors, null); module.exports = { machine: machine, vehicle: vehicle, robot: robot }