js ~~ 符号

其实是一种利用符号进行的类型转换,转换成数字类型

[pcsh lang="js" tab_size="4" message="" hl_lines="" provider="manual"]

~~true == 1
~~false == 0
~~"" == 0
~~[] == 0

~~undefined ==0
~~!undefined == 1
~~null == 0
~~!null == 1

[/pcsh]

 

此处评论已关闭