JS中有效判断一个值是否是 null 或 undefined

上代码:

 if ( some_variable == null ){
   // some_variable is either null or undefined
 }

更多代码:

if ( !some_variable ) {
  // some_variable is either null, undefined, 0, NaN, false, or an empty string
}
发布了188 篇原创文章 · 获赞 88 · 访问量 58万+

猜你喜欢

转载自blog.csdn.net/henryhu712/article/details/103751055