1、二级制操作优于Math

如:



//函数向下取整
console.log(Math.floor(8.9));
//二进制向下取整
console.log(8.9>>0);


2、慎用||

大量运用if(x === null){ x={} } 优于x=x||{}

3、switch 性能优于if...else if...


作者:孟繁贵