About Jerone v1.4

This text should not be seen and spoken.

Adbanner

ad

ad

ad

ad

Validate

Valid XHTML 1.0 Transitional

Valid XHTML 1.0 Strict

Valid XHTML 1.1

Valid CSS 2

Valid CSS 3

Array.prototype.find

Find a string or regexp in a array.

See source for the example code and below for correct code.

03-01-2007Code for Array Find

// Find in array (position);
// e.g.:	testArray.find("test");
// e.g.:	testArray.find(/^blue/i);
// return:	[integer or boolean] returns position or if not excised false;
// syntax:	Array	[object Array] array used to search in;
//			str		[string or regexp] value to look for, can be string or regexp;
Array.prototype.find = function(str) {
	var returnArray = false;
	for (i=0; i < this.length; i++) {
		if (typeof(str) == 'function') {
			if (str.test(this[i])) {
				if (!returnArray) {
					returnArray = [];
				}
				returnArray.push(i);
			}
		}
		else {
			if (this[i]===str) {
				if (!returnArray) {
					returnArray = [];
				}
				returnArray.push(i);
			}
		}
	}
	return returnArray;
};

Array Find v1
This text should not be seen and spoken.