3 ms·
The algorithm for "var p = new Person" is roughly (ignoring prototypes): var p = {}; Person.call(p); // calls Person with p as this Remember that in j
by hdhzy 10y ago
The algorithm for "var p = new Person" is roughly (ignoring prototypes):
var p = {};
Person.call(p); // calls Person with p as this
Remember that in js there are no "methods" just functions. The original constructor function can be accessed by "constructor" property: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/constructor https://developer.mozilla.org/en-US/docs/Web/JavaScript/Refe...