I am having an array of object like the following:
let data = [{
name: "Product1",
category: "category 1"
}, {
name: "Product2",
category: "category 2"
}, {
name: "Product3",
category: "category 3"
}, {
name: "Product4",
category: "category 4"
}]
var flattened = [].concat.apply([], data);
console.log(flattened)
// expected output:
// ["Product1", "Product2", "Product3", "Product4"]
See above what I tried. However, I would like to have the following expected output: ["Product1", "Product2", "Product3", "Product4"]
Any suggestions what I am doing wrong?
I appreciate your replies!