CoderZone.org

Category: >> JavaScript >> Handy In_Array() Just Like In PHP Bookmark and Share

<< lastnext >>

Snippet Name: Handy In_Array() Just Like In PHP

Description: This function searches an array for a specified element, just like the in_array() function in PHP.

Also see:
» Get every 2nd (or 3rd, 4th, ...) e...
» Grab the last element of an array
» Get the computed style of an eleme...
» Find All Elements By Class
» Dynamically create HTML elements
» Add PSOUG Search to SQL Developer
» Dynamically add and remove elements
» Search and Replace On Every Field ...
» Search array elements for a substr...
» Search All Words Of A String In my...
» Unset unkown array element
» FLASHBACK: Syntax Elements
» Search PL/SQL for a string/ key va...
» Inline search and replace
» SELECT: Case insensitive search
» Extract Search Query from Referer
» Search and Replace
» Filter Empty Array Elements

Comment: (none)

Author: CoderZone
Language: JAVASCRIPT
Highlight Mode: JAVASCRIPT
Last Modified: December 01st, 2010

Array.prototype.in_array = function(test_val) {
	for(var i = 0, l = this.length; i < l; i++) {
		if(this[i] == test_val) {
			return true;
		}
	}
	return false;
}
 
 
There haven't been any comments added for this snippet yet. You may add one if you like.  Add a comment 
© coderzone.org | users online: 7