位运算
1.除以2并取整
var x = 21 let right = x >> 1; // 除以2并取整,缩小一下遍历的范围 console.log('right=', right) //10
2.~操作
按位取反
var ifRange = "123456"; var x = ~ifRange.indexOf('"') ? "45" :"66"; //66 x ~ifRange.indexOf('"')为0 ~ifRange 为"-123457"
console.log(x);
1.除以2并取整
var x = 21 let right = x >> 1; // 除以2并取整,缩小一下遍历的范围 console.log('right=', right) //10
2.~操作
按位取反
var ifRange = "123456"; var x = ~ifRange.indexOf('"') ? "45" :"66"; //66 x ~ifRange.indexOf('"')为0 ~ifRange 为"-123457"
console.log(x);