1、删除一个元素
arr.splice(arr.findIndex(v => v.key === 'demokey'),1);
2、根据某个字段就行排序
function compare(p) {
return function (m, n) {
const a = m[p];
const b = n[p];
return b - a;
}
}
myDeparts.sort(compare("role"));
3、在数组开头新增元素
arr.unshift()