javascript - How can an object's property access other property? -


this question has answer here:

why can't in javascript?

var big = { a:1, b:2, c:3, d:big.a }

how can object's 1 property access another?

//--------------------------------edited below ----------------------------------

thanks answers, found question:

when this:

var big =  {         : 1,         b : 2,         c : 3,         d : this.a     }    console.log(big.d); 

it's undefined

however, when this:

var big =  {         : 1,         b : 2,         c : 3,         d : function(){console.log(this.a)}     }   big.d(); 

it logs out 1

i wonder what's going on here, because function in second code somehow makes 'this' accessible?

thanks.

you can

var big = { a:1, b:2, c:3}; big.d = big.a; 

in code when using d:big.a still not defined i'e. big not defined


Comments

Popular posts from this blog

how to proxy from https to http with lighttpd -

android - Automated my builds -

python - Flask migration error -