How to access outer object in javascript objects -


assume code like. want access , j in function somefunc. how achieved?

var myobj = function(){ object.defineproperty(this, 'j'){  get: function() { return 1;} }; }  myobj.prototype =  object.create(null); myobj.prototype={    constructor : myobj,    : 1,    somefunc : function(){        console.log(i + j);    } } 

they can accessed through this.i , this.j

var myobj = function(){     object.defineproperty(this, 'j'){         get: function() { return 1;}     }; }  myobj.prototype =  object.create(null); myobj.prototype={    constructor : myobj,    : 1,    somefunc : function(){        console.log(this.i + this.j);    } } 

Comments

Popular posts from this blog

php - Why I am getting the Error "Commands out of sync; you can't run this command now" -

ruby - Nesting modules inside of a Rails eninge gem -

Eclipse formatter for java ending braces -