new object is created. Used as `this` in the function context _this.__proto__ = Criminal.prototype; // a special __proto__ property is set Criminal.call(_this); return _this; // newly created object is returned } var some_dude = newCriminal(); some_dude.murder("George Woosh"); fake new function newCriminal () { var _this = {}; // (A) _this.__proto__ = Criminal.prototype; // (B) Criminal.call(_this); return _this; // (C) } var some_dude = newCriminal(); some_dude.murder("George Woosh");
console.log("Yes, we can!”); }; var lee_oswald = new Criminal(); Object.setPrototypeOf(lee_oswald, President.prototype); lee_oswald.__proto__ = President.prototype; lee_oswald.speak(); // OK, this is awkward __pr0to!