Skip to content
Find file
Fetching contributors…
Cannot retrieve contributors at this time
20 lines (11 sloc) 415 Bytes

Prefilter JSON

The filter() method creates a new array with all elements that pass the test implemented by the provided function.

So when you don't want to work with all the elements from the array then you can use filter.

Let's filter out the cat who's "id" key has a value of 1.

Here's the code to do this:

json = json.filter(function(val) {

  return(val.id !== 1);

});

More about filter:

Something went wrong with that request. Please try again.