Essentially, I want to implement the following:
var categories = [];
var products =
products.map(function(value) {
if(categories.indexOf(value.Category === -1)) categories.push(value.Category);
});
As a result, the array categoriescontains a unique list of product categories.
I feel that there should be a better way to do this, but nothing comes to mind.
If not, then it probably makes no sense to use it map()first. I could do as simple as
var categories = [];
var products =
for (var i = 0; i < products.length; i++) {
if(categories.indexOf(products[i].Category === -1)) categories.push(products[i].Category);
}
UPDATE , , . , , . , . , . , , , . ,