微信小程序 undefined 判斷

微信小程序undefined

微信小程序 Object 對象,Object的值是 primitive value。即 number、string、boolean、null、undefined小程序

錯誤用法

if(options.name != 'undefined'){
// 只要沒有定義爲undefined ,都會走到這裏,不是咱們指望的
}

file

正確用法

if(options.name != undefined){ //這裏的 undefined 沒有引號
// 只要沒有定義爲undefined ,都會走到這裏,不是咱們指望的
}
相關文章
相關標籤/搜索