Monday, August 27, 2012

scope – Understanding the "|| {}" construct in javascript


Possible Duplicate:

What does “var FOO = FOO || {}” mean in Javascript?

Javascript – Can you add condition to variable declaration



I believe this has to do with scoping, and not redefining scope. I see a lot of this in popular javascript frameworks:



var something = something || {};


Is that to do with not accidentally redefining a top-level variable?






Rating: 1 out of 5 based on 8 ratings



The post scope – Understanding the "|| {}" construct in javascript appeared first on Javascript ASK.






via Javascript ASK http://javascriptask.phpfogapp.com/scope-understanding-the-construct-in-javascript.html

No comments:

Post a Comment