2019-06-30

JavaScript - jQuery Grep

// Arry of json objects
let json = [
{
"item_name": "United States"
, "item_property": "123"
},
{
"item_name": "United Arab Emirates"
, "item_property": "123"
},
{
"item_name": "Mexico"
, "item_property": "234"
}
];

// Grep to filter
$.grep( 
json
, function( item, index ) {
return item.item_property === '123';
}
);


No comments:

Post a Comment