![](https://img-blog.csdnimg.cn/20201014180756926.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
javascript
puppet_
keep on going!
展开
-
js数组去重
Array.prototype.unique1 = function() { var n = []; //一个新的临时数组 for(var i = 0; i { //如果当前数组的第i已经保存进了临时数组,那么跳过, //否则把当前项push到临时数组里面 if (n.indexOf(this[i]) == -1) n.push(this[i]); } return n; }转载 2016-12-21 21:26:47 · 237 阅读 · 0 评论 -
js小数取整处理
1.丢弃小数部分,保留整数部分 js:parseInt(7/2) 2.向上取整,有小数就整数部分加1 js: Math.ceil(7/2) 3,四舍五入. js: Math.round(7/2) 4,向下取整 js: Math.floor(7/2)原创 2017-05-02 16:58:17 · 433 阅读 · 0 评论