Equivalent de la fonction PHP in_array() en JavaScript
0
Array.prototype.in_array = function(p_val) { for(var i = 0, l = this.length; i < l; i++) { if(this[i] == p_val) { return true; } } return false; } Exemple : var v_array = [ 5, 10, 15, 20, 25]; document.writeln(v_array.in_array(10)); // true
DATE 22 Oct 2010