Javascript variable lifecycle, will the variable be copied when it is returned?

Catteundura

New Member
It is hard to describe the situation without code.My modification made some answers irrelevant. I past the original code here and simplified version below:\[code\]function Entity(){ var value = http://stackoverflow.com/questions/15714590/{}; return {'value': value };}var e1 = Entity();var e2 = Entity();alert(e1.value =http://stackoverflow.com/questions/15714590/== e2.value);\[/code\]I thought it should return true. But in fact, it returns false. Is 'value' copied when it is returned from the function Entity?updateI think I know the reason now. each time Entity function is called the expression "var value=http://stackoverflow.com/questions/15714590/{};" will generate a new Object. Thanks.
 
Back
Top