javascript - How to access outer object's attribute from an inner object? -


can outer's value accessed function of inner object? there way?

var outer = {     value: "1",     inner: {         getvalue: function() {             return value; // undefined         }     } }  alert(outer.inner.getvalue()); // fails 

there no way refer containing object, "inner" object have infinite number of containing objects. have explicit , give reference parent object.

var outer = { ... };  var inner = {   parent: outer,   getvalue: function () { return this.parent.value() } } 

Comments

Popular posts from this blog

android - Get AccessToken using signpost OAuth without opening a browser (Two legged Oauth) -

org.mockito.exceptions.misusing.InvalidUseOfMatchersException: mockito -

google shop client API returns 400 bad request error while adding an item -