一个数组["125","445","22","45","68","32","98"],想要变成[125,445,22,45,68,32,98],不用for循环,怎么做
ringa_lee2017-04-10 15:31:12
(function(){
var arr = ["125","445","22","45","68","32","98"];
arr = arr.map(function(el){return parseInt(el);});
});
PHP中文网2017-04-10 15:31:12
php
//其实也是循环 var arr=["125","445","22","45","68","32","98"].map(function(i){ return +i; }) console.log(arr);
大家讲道理2017-04-10 15:31:12
a.reduce(function(prev, a){ prev.push(+a); return prev;}, []);
//其实还是循环