![](https://img-blog.csdnimg.cn/20201014180756916.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
数组的使用
Wan~naW
前端白小白
展开
-
遍历数组中的选项得到某个属性值
//遍历数组中的对象得到某个属性值(返回新数组) getArrayProps(array, key) { var key = key || "value"; var res = []; if (array) { array.forEach(function (t) { res.push(t[key]); ...原创 2020-02-21 21:23:34 · 1959 阅读 · 0 评论 -
让数组中的字符串类型转为数字在相加
//让数组中的字符串变成数字然后相加 num=['1','2','4','5','7'] let arr = num.map(Number) let total = arr.reduce(function (sum, current) { return sum + current; }, 0); ...原创 2020-02-17 17:54:39 · 1279 阅读 · 0 评论