const cars = [{
\t brand: 'BMW',
\t year: '1997'
}, {
\t brand: 'BMW',
\t year: '2011'
}]
Object.keys(cars).forEach(function(x) {
\t if (cars[x].brand == "BMW") {
\t \t console.log(cars[x]);
\t }
});
如何CONSOLE.LOG阵列相匹配的品牌“宝马”的只有第一个对象? *它必须是与对象键
'cars'是一个数组。为什么要使用Object.keys()'? Oo – Andreas