1.4.Object
var switchPotato = { state: false; isOn: function isOn{ return this.state; }, toggle: function toggle(){ this.state = !this.state; return this; }, meta: { name: 'light switch' } }, switch1 = Object.create(switchPotato), switch2 = Object.create(switchPotato); test('Prototype mutations', function(){ switch2.meta.name = 'Breaker switch'; equal(switch1.meta.name, 'Breaker switch', 'Object and array mutations are shared'); switch2.meta = {name : 'Power switch'}; equal(switch1.meta.name, 'Breaker switch', 'Property replacement is instance-specific'); });
Last updated


