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

linux - Does gcc have any options to add version info in ELF binary file? -

android - send complex objects as post php java -

charts - What graph/dashboard product is facebook using in Dashboard: PUE & WUE -