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-01-09
  • 2021-12-08
  • 2021-06-15
  • 2021-05-17
  • 2021-12-21
猜你喜欢
  • 2022-01-01
  • 2021-06-08
  • 2022-01-23
  • 2021-08-01
  • 2022-02-13
  • 2021-08-21
  • 2022-02-04
相关资源
相似解决方案