先說(shuō)switch:var a = [];switch (a.constructor){ case String: console.log('string') break; case Array: console.log('array'); break; default: console.log('wrong'); break;
}這里得到的結(jié)果是字符串a(chǎn)rray,但是當(dāng)我這樣子的時(shí)候:a.contructor == Array // false這是為什么?是switch做了什么轉(zhuǎn)換嗎?另外一個(gè)問(wèn)題:let a = []; // node環(huán)境下
console.log(a.constructor) // SyntaxError: Block-scoped declarations (let, const, function, class) not yet supported outside strict mode這是為什么?
js的switch和let的問(wèn)題
ITMISS
2018-08-10 09:10:13