首页 > 代码库 > JS的知识补丁

JS的知识补丁

1:javascript 有符号右移0位用于取整。

 1 var a = (-0.331*1) >> 0;
 2         b = (-0.331*10) >> 0,
 3         c = (-0.331*100) >> 0,
 4         e = (0.331*1) >> 0,
 5         f = (0.331*10) >> 0,
 6     console.log(a);//0
 7     console.log(b);//-3
 8     console.log(c);//-33
 9     console.log(e);//0
10     console.log(f);//3

 

JS的知识补丁