转数值类型并取整


      转数值类型并取整

       

var a = '10.567890'|0;   

var b = '10.567890'^0;   

var c = -2.23456789|0;  

var d = ~~-2.23456789;   

alert("a:" + a +",b:"+ b + ",c:" + c +",d:" + d) //a:10,b:10,c:-2,d:-2

alert("a:" + typeof (a) +",b:"+ typeof (b) + ",c:" + typeof (c) +",d:" + typeof (d))  //a:number,b:number,c:number,d:number




你可能感兴趣的:(javascript)