Dùng từ khóa delete để xóa thuộc tính của đối tượng trong mảng.
Mã thực hiện
var details = [
{ customerName: "Chris", customerAge: 32 },
{ customerName: "David", customerAge: 26 },
{ customerName: "Bob", customerAge: 29 },
{ customerName: "Carol", customerAge: 25 }
];
delete details[0].customerAge;
console.log(details);
Kết quả
[ { customerName: 'Chris' }, { customerName: 'David', customerAge: 26 }, { customerName: 'Bob', customerAge: 29 }, { customerName: 'Carol', customerAge: 25 } ]