删除数组
arr
中isDefault属性为false
的元素
arr = arr.filter(({ isDefault }) => isDefault !== false);
原数组arr:
[
{
"type": "selection",
"width": 60,
"align": "center",
"fixed": "left",
},
{
"title": "主机名",
"key": "hostname",
"minWidth": 120,
"align": "center",
"isDefault": true,
},
{
"title": "产品线",
"key": "product",
"minWidth": 120,
"align": "center",
"isDefault": false,
},
{
"title": "机房",
"key": "idc",
"minWidth": 120,
"align": "center",
"isDefault": true,
}
{
"title": "安装镜像",
"key": "os",
"minWidth": 120,
"align": "center",
"isDefault": false,
},
{
"title": "操作状态",
"key": "op_status",
"minWidth": 120,
"align": "center",
"isDefault": false,
},
{
"title": "操作",
"key": "details",
"minWidth": 120,
"align": "center",
"isDefault": true,
}
]
删除后:
[
{
"type": "selection",
"width": 60,
"align": "center",
"fixed": "left",
},
{
"title": "主机名",
"key": "hostname",
"minWidth": 120,
"align": "center",
"isDefault": true,
},
{
"title": "机房",
"key": "idc",
"minWidth": 120,
"align": "center",
"isDefault": true,
},
{
"title": "操作",
"key": "details",
"minWidth": 120,
"align": "center",
"isDefault": true,
}
]