Javascript Array inArray(val) method
Array.prototype.inArray = function(val) { var l = this.length; for(var i = 0; i < l; i++) { if(this[i] == val) { return true; }/*from w w w. j a va 2s . c om*/ } return false; }
Array.prototype.inArray = function(val){ for (var key in this){ if(this[key] == val) {/* w w w . j a v a 2s.co m*/ return true; } }; return false; }
Array.prototype.inArray= function(i){ var _this = this; for(var x=0; x<_this.length; x++){ if(_this[x]==i) return x; }//www. j av a 2 s. co m return -1; }
Array.prototype.inArray = function (value) { var i;//from w w w.ja va2 s .c o m for (i=0; i < this.length; i++) { if (this[i] === value) { return true; } } return false; };
///*from w ww. j a v a2 s.c o m*/ Array.prototype.inArray = function (value){ var i; for (i=0; i < this.length; i++) { if (this[i] === value) { return true; } } return false; };
if (!invo.lang) { invo.lang = {}; } /*/*from ww w .java2 s .c o m*/ JS has no built in function for inArray, so I have borrowed this one, used by a bajillion different people. Note that you can change the === is only available in modern JS implementations. it tests to see if the value passed in is both a) the same name and b) the same object type. */ Array.prototype.inArray = function (value) { for (var i=0; i < this.length; i++) { if (this[i] === value) { return true; } } return false; };
// Determine wheter an element is in the array or not Array.prototype.inArray = function (value) { var index = this.indexOf(value) if (index != -1) { return true//from w w w . j ava2s.com } return false }