JavaScript 里 var a = a || {} 啥意思?
var a;
if(a === 0 || a === "" || a === false || a === null || a === undefined) a = {}
那句话的定义。还有你这种情况 a 是函数的入口参数吧,代码是这样的对吧
function(a){
var a = a || {}
}
它等价于
function(a){
if(a === 0 || a === "" || a === false || a === null || a === undefined) a = {}
}
作者:Belleve
链接:https://www.zhihu.com/question/22914542/answer/23111563
来源:知乎
著作权归作者所有。商业转载请联系作者获得授权,非商业转载请注明出处。