刪除數組
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,
}
]