Javascript中的神器字符 [ , ] , ( , ) ,
2017-04-28 本文已影响1人
秋秋秋web
黄金法则:
!后面跟的字符会被转换成布尔值
+后面跟的字符会被转换成数值
[]后面跟的字符会被转换成字符串
举个例子:
! [ ] === false
+ [ ] === 0
[ ] + [ ] === ""
" hello " [ 0 ] === " h "
( ! [ ] + [ ] ) [ + !! [ ] ] === " a " // " false " [1]