ben在a没有赋值时候返回数组,当a有值时候返回a(一般a为ben的上次值)
var a=[1,2,3]
var ben =a || [];
console.log(ben); //[1,2,3]
var a;
var ben =a || [];
console.log(ben); //[]
var a=[1,2,3]
var ben =a || [];
ben.push(4);
console.log(ben); //[1,2,3,4]
ben在a没有赋值时候返回数组,当a有值时候返回a(一般a为ben的上次值)
var a=[1,2,3]
var ben =a || [];
console.log(ben); //[1,2,3]
var a;
var ben =a || [];
console.log(ben); //[]
var a=[1,2,3]
var ben =a || [];
ben.push(4);
console.log(ben); //[1,2,3,4]