const data=[
{
name:'zhangsan',
age: 20 ,
},
{
name:'lisi',
age: 30 ,
}
];
data.reduce((pre,cur)=>{return pre+cur.age},0);
pre值为0,cur为数组第一个对象
const data=[
{
name:'zhangsan',
age: 20 ,
},
{
name:'lisi',
age: 30 ,
}
];
data.reduce((pre,cur)=>{return pre+cur.age},0);
pre值为0,cur为数组第一个对象