1.2.2.5.存在與布林
null, undefined, ""在強制型轉後會成為false
可利用這個特性來判斷變數是否存在
var a;
// goes to internet and looks for a value
if (a || a === 0) {
console.log('Something is there.');
}
Last updated
Was this helpful?
null, undefined, ""在強制型轉後會成為false
可利用這個特性來判斷變數是否存在
var a;
// goes to internet and looks for a value
if (a || a === 0) {
console.log('Something is there.');
}
Last updated
Was this helpful?