Possible Duplicate:
What does “options = options || {}” mean in Javascript?
Hi I am not so good with javascript. I have searched all over the place and didn’t find anything which relates to my query.
I’ve been seeing a lot of this lately and a bit curious what does this mean?
someValue || {} in javascript?
Thank you much for you help!
If
someValue‘s value is falsy like:nullfalseundefinedthen
someValuedefaults to an object{}.The
||used this way is also known as “default”, meaning that if the value to the left of a||is falsy, it “defaults” to the value at the right.