lundi 22 août 2016

Javascript constructor called with extra param: 'this'?

I have one js file calling an object's constructor but with an additional parameter (this) pre-pended to the argument list. I'm guessing this has something to do with the inheritance but I just don't know. (My background is Java.)

index.js

var AlexaSkill = require('./AlexaSkill');
var Josephine = function () {
    AlexaSkill.call(this, APP_ID);
};

AlexaSkill.js

function AlexaSkill(appId) {
    this._appId = appId;
}

Aucun commentaire:

Enregistrer un commentaire