Return to Snippet

Revision: 2410
at February 9, 2007 06:15 by clapfouine


Initial Code
Array.prototype.inArray = function(valeur) {
	for (var i in this) { if (this[i] === valeur) return i; }
	return -1;
}

/*
in_array() renvois la clef si la valeur est présente, sinon, renvoie -1. \\ exemple : \\

var t=new Array("coucou","test","plop");
alert(    t.in_array("test")   ); //affichera 1
alert(    t.in_array("bobo")   ); //affichera -1
*/

Initial URL

                                

Initial Description

                                

Initial Title
inArray prototype

Initial Tags
javascript, search, array

Initial Language
JavaScript