JavaScript判断非空的语句一般为:

var elvis;
if (typeof elvis !== "undefined" && elvis !== null) {
  alert("Elvis isn't a null object!");
}

当然,如果你使用CoffeeScript的话,写法就更简单了:

alert "Elvis isn't a null object!" if elvis?

版权声明:本文为博主原创文章,未经博主允许不得转载。

相关文章:

  • 2022-12-23
  • 2021-11-28
  • 2022-12-23
  • 2021-07-21
  • 2022-12-23
  • 2021-11-28
  • 2021-06-02
  • 2022-12-23
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2021-10-16
  • 2021-10-15
  • 2022-12-23
相关资源
相似解决方案