Saturday, 31 August 2013

How does this work in javascript

How does this work in javascript

var temp = temp || {};
In the above syntax temp is created if it is not already exist otherwise
it will refer to the variable which was already created. Just I am curious
that how does this work. I think right side of expression should return
true if temp exists but it is creating an object. How does this work. Any
explanation would be helpful.

No comments:

Post a Comment