how to get parent object property in javascript/jQuery -


i've been searching way parent object property in nested object had no luck.

here nested object using:

var obj = {         name: 'my name',         obj1: {                  age: 18,                  name: this.name             }     }; 

but gives , undefined error.

is there way in javascript or jquery achieve it?

you can :

var obj = new obj();  function obj(){     var self = this;     self.name = 'my name';     self.obj1 = {         age: 18,         name: self.name     } }; 

Comments

Popular posts from this blog

html5 - What is breaking my page when printing? -

c# - must be a non-abstract type with a public parameterless constructor in redis -

ajax - PHP/JSON Login script (Twitter style) not setting sessions -