我如何检查的财产包括在JS对象的数组?
const array=[
{ name: "A", hasCar: true},
{ name: "B" }
];
// if (array has "hasCar") {
// do something
// }
我想,如果阵列有qazxsw POI与否。 qazxsw POI不上对象的数组工作。
我应该使用"hasCar"
或任何解决方案?
你可以采取array.includes
与.hasOwnProperty("hasCar")
检查。