How do JavaScript engines create variables? -
How do JavaScript engines create variables? -
consider:
var s1 = { a: 1, b: s1.a }; alert(s1.b); // uncaught typeerror: cannot read property 'a' of undefined
can shed lite on inner workings of javascript engines why case?
currently i'm forced use:
var s2 = { a: { a: 1 }, b: { a: function () { homecoming s2.a.a} } }; alert(s2.b.a()); // 1
inside of declaration:
var s1 = { a: 1, b: s1.a };
s1
not yet defined until end of info declaration, cannot referred within of info declaration. how javascript works.
you instead:
var s1 = { a: 1 }; s1.b = s1.a;
javascript
Comments
Post a Comment