标签:java for ar art new javascript on c as
在javascript中按位取反再取反可以将一个浮点数的转化为整形,而且其效率要比parseInt高出将近一倍
var start = new Date().getTime(); for (var i = 0; i < 10000000; i++) { var a = Math.random() * 5; ~~a; } console.info(new Date().getTime() - start); start = new Date().getTime(); for (var i = 0; i < 10000000; i++) { var a = Math.random() * 5; parseInt(a); } console.info(new Date().getTime() - start.getTime());
标签:java for ar art new javascript on c as
原文地址:http://blog.csdn.net/songzheng_741/article/details/38829173