0、''、undefined、null、NAN比较

0、''、undefined、null、NAN比较

用Boolean函数能将5个表达式(0、''、undefined、null、NAN)转换成false,其他的情况为true。if语句就是用Boolean函数转为true或者false,继而根据结果执行后面的语句的。非运算符也是先用Boolean函数将运算符后的表达式转换后才继续执行后续操作的。

if (0) 等于if (Boolean(0))

同理:

if(!0) 等于if(!Boolean(0))

与0同样的有 ""、null、unedefined、NAN


相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-08-01
  • 2022-01-23
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2022-12-23
  • 2022-01-01
  • 2019-09-19
  • 2022-12-23
  • 2017-12-05
  • 2021-06-08
  • 2022-12-23
相关资源
相似解决方案