let products=[
{name:"cucmber",age:18},
{name:"xiaoming",age:20},
{name:"xiaohua",age:34}
];
console.log(products);
//foreach
products.forEach(product=>product.age+=2);
console.log(products);
//filter
let res=products.filter(product=>product.age>=20)
console.log(res);
//map
let mapres=products.map(product=>product.name);
console.log(mapres);
//find 找到第一个符合的
let findres=products.find(product=>product.name==="xiao")
console.log(findres)
//sonme ||
let someres=products.some(product=>product.age>20)
console.log(someres)
let everyres=products.every(product=>product.age>20)
console.log(everyres)
//reduce
let reudceRes=products.reduce(function(newArry,product){
newArry.push(product.name);
return newArry
},[])
console.log(reudceRes)
//使用filter和match实现前端模糊查询
let res2=products.filter(product=>product.name.match("m"))
console.log(res2)
console