build 5delFlag falsedeviceType cameradeviceTypeName 枪式摄像机floor 14height 56id 261ip 101161latitude 0000609longitude -000004name 楼顶-东侧楼梯status 0数组用 js 过滤 status 1
在JavaScript中,我们可以使用filter()方法来过滤数组。根据给出的条件,我们可以使用以下代码过滤status为1的对象:
const data = [
{
build: "5",
delFlag: false,
deviceType: "camera",
deviceTypeName: "枪式摄像机",
floor: "14",
height: "56",
id: "261",
ip: "10.11.6.1",
latitude: "0.000609",
longitude: "-0.00004",
name: "楼顶-东侧楼梯",
status: "0"
}
// 其他对象...
];
const filteredData = data.filter(obj => obj.status === "1");
console.log(filteredData);
在上面的代码中,filter()方法将会返回一个新的数组,其中包含了满足条件obj.status === "1"的对象
原文地址: http://www.cveoy.top/t/topic/ijBt 著作权归作者所有。请勿转载和采集!