javascript - Get "this" within the parent class -
my problem can't access proper this object in parent class.
parent class :
viewcontroller.prototype.display = function() { console.log(this); // log window object };
child class :
parentmissionsviewcontroller.prototype = object.create(viewcontroller.prototype); parentmissionsviewcontroller.prototype.constructor = parentmissionsviewcontroller; parentmissionsviewcontroller.prototype.parent = viewcontroller.prototype; parentmissionsviewcontroller.prototype.display = function() { // other stuff here this.parent.display.call(); };
i don't why isn't current object, if can explain me ?
if call
this.parent.display();
then looks like:
var = this.parent; that.display();
which you, suppose, wanted avert. using call
way, need provide value this
:
this.parent.display.call(this /* , arg, arg... */);
Comments
Post a Comment