what does this mean? javascript question
var a = wi开发者_运维问答ndow.a || {};
It means a
will be assigned window.a
if it is not null or undefined, otherwise, it will equal an empty object
To answer the unasked question: this is used to make sure "a" will be valid.
Without it, when calling a.someFieldHere you might get exception saying "a is undefined", with such code in place you won't get such error.
It's useful when "a" is created elsewhere in some other code that not always get executed.
Kind of insurance policy. :)
精彩评论