Keep this as context of base object in properties of javascript object -


i wondering need maintain type of (var self = this) coupling within sub properties of java script object. example, if had following object:

var t = {     helpers: {         getname: function(){             //how preserve or mbase object instance here...             //so can example following:             var self = this;//this helpers object, how base object?             return self.nickname + "...";         },         gettime: function(){          }     },     nickname: 'test' } 

from understand currently, reference when in object, directly passed down function if property of object. since scenario 2 objects don, base or "helpers" object when reference (var self = this) , if so, how reach base object property such "nicknam" within obj.helpers.getnickname()?

thanks in advance.


Comments

Popular posts from this blog

java - nested exception is org.hibernate.exception.SQLGrammarException: could not extract ResultSet Hibernate+SpringMVC -

sql - Postgresql tables exists, but getting "relation does not exist" when querying -

asp.net mvc - breakpoint on javascript in CSHTML? -