获得徽章 0
- js双位运算符 可以用来代替Math.floor();
并且会比Math.floor()速度快一些
~~1.1 = 1
~~-3.4 = 3
需要注意的是 -3.4 返回的是 -3
console.time('floor');
for(let item of new Array(10000).fill(Math.random())){
Math.floor(item)
}
console.timeEnd('floor')
console.time('~~~');
for(let item of new Array(10000).fill(Math.random())){
~~item
}
console.timeEnd('~~~')展开赞过评论2