JSFiddle - React, Tailwind, and code Playground
by jelontok
JavaScript
var catalog={
products : [
{ category: 'fos', name: 'retek' },
{ category: 'fos', name: 'item' },
{ category: 'nyedva', name: 'blabla' },
{ category: 'fos', name: 'gihi' },
]
};
var categories = [];
$.each(catalog.products, function(index, value) {
if ($.inArray(value.category, categories)==-1) {
categories.push(value.category);
}
});
console.log(categories);