Showing posts with label filtering. Show all posts
Showing posts with label filtering. Show all posts

Thursday, June 3, 2010

Filtering JavaScript Arrays

Below is an example of how you can filter a JavaScript array using jQuery


var foo = new Array(5);
foo[0] = "zero";
foo[1] = "one";
foo[2] = "two";
foo[3] = "three";
foo[4] = "four";

alert(foo);

fooSelected = jQuery.grep(foo, function(value) {
return value != "three";
} );

alert(fooSelected);