比如这段代码:
~id.indexOf('offcanvas-with-right') ? "close" : "none";
Longyang
- 发布:2015-07-09 14:00
- 更新:2015-12-18 11:40
- 阅读:3298
~id.indexOf()前面的波浪号啥意思?
分类:MUI
1 个回复
Seven_Tao
~id.indexOf('offcanvas-with-right')
等同于
id.indexOf('offcanvas-with-right') > -1
波浪号可以做运算
~N == -(N+1)
~-1 = -(-1+1) = 0
~1 = -(1+1) = -2
也可以转义
~~'123' == 123
~~'-123' == -123
~~true == 1
~~false == 0