1. js 中为了省字节,性能, 防止被重写等发明了各种写法,记录下
1 //取整 2 parseInt(a,10); //Before 3 Math.floor(a); //Before 4 a>>0; //Before 5 ~~a; //After 6 a|0; //After 7 8 //四舍五入 9 Math.round(a); //Before10 a+.5|0; //After11 12 //内置值13 undefined; //Before14 void 0; //After, 快15 0[0]; //After, 略慢16 17 //内置值18 Infinity;19 1/0;20 21 //布尔值短写法22 true; //Before23 !0; //After24 25 //布尔值短写法26 false; //Before27 !1; //After