js 对数组对象进行操作?

发布网友 发布时间:2022-04-24 14:04

我来回答

1个回答

热心网友 时间:2022-04-28 00:37

var arr=[{name: 'cst', age: '18'}, {name: 'jc', age: '20'}, {name: 'dxm', age: '50'} , {name: 'dcg', age: '30'}];
let brr=arr.filter(n => {
return n.name.indexOf('c')>-1;
}).map(a => {
a.age=(Number(a.age)+1).toString();
return a;
});
console.log(brr);

热心网友 时间:2022-04-28 00:37

var arr=[{name: 'cst', age: '18'}, {name: 'jc', age: '20'}, {name: 'dxm', age: '50'} , {name: 'dcg', age: '30'}];
let brr=arr.filter(n => {
return n.name.indexOf('c')>-1;
}).map(a => {
a.age=(Number(a.age)+1).toString();
return a;
});
console.log(brr);

声明声明:本网页内容为用户发布,旨在传播知识,不代表本网认同其观点,若有侵权等问题请及时与本网联系,我们将在第一时间删除处理。E-MAIL:11247931@qq.com