Hacker News new | ask | show | jobs
by hdhzy 3360 days 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/Refe...