Re: How can I call variable in script like this global.var

Boris Zbarsky <[email protected]> Mon, 1 Apr 2019 14:16:52 -0400
Newsgroups gmane.comp.mozilla.devel.jseng
Message-ID <[email protected]>
On 4/1/19 12:58 PM, muhammad sami wrote:
> I ran this script over global 'var x = 5 ; var global = this; global.x' works perfectly, the I created another global object which has global as a prototype
> 
> I ran this script over child object 'var x = 10 ; var child = this; child.x'

OK.  So now you have two objects, right?  You have "child", which has a 
property named "x", which has the value 10.  And its prototype is 
"global" (which happens to be a global too, but that's not really 
important here, afaict), which also has a property named "x", which has 
the value 5.

> but x=child.x=global.x  which totally make scence as child=global=this

That's a bit odd.  I would expect x == child.x == 10 and global.x == 5 
in your situation, if I understood it correctly.  What does the actual 
code you're using look like?

-Boris