I’m trying to remove specific object property of objects in array. Look at the code:
let propertyToRemove = "product"; // propertyToRemove could be anything, "cost", ...
let array = [
{product: "pen", cost: 2, color: "blue", ...}, // ... means there are other properties
{product: "pencil", cost: 1, color: "red", ...},
{product: "book", cost: 4, color: "purple", ...}
]
Expected output:
let array = [
{cost: 2, color: "blue", ...},
{cost: 1, color: "red", ...},
{cost: 4, color: "purple", ...}
]
How could it be achieved? Any support is much appreciated.