myNew keywordfunc

Run Settings
LanguageJavaScript
Language Version
Run Command
// My thanks to MPJ. //code snnipet based on mpjs video about object creation:https://www.youtube.com/watch?v=Y3zzCY62NYc let Person = function(saying){ this.saying = saying; } Person.prototype.talk = function(){ console.log('i say:', this.saying); } let myNew = function(constructor){ let obj = Object.create(constructor.prototype); //{} //Object.setPrototypeOf(obj,constructor.prototype); let args = Array.from(arguments); constructor.apply(obj, args.slice(1)); return obj; } //let mpj = new Person('Good monday morning.'); let mpj = myNew(Person,'Good monday morning.'); mpj.talk();
Editor Settings
Theme
Key bindings
Full width
Lines