Javascript Array contains(item)
Array.prototype.contains = function(item){ return RegExp("\\b"+item+"\\b").test(this); };
'use strict';//w w w . ja va2 s . c o m function get_intersection(collection_a, collection_b) { var result = []; for (var i = 0; i < collection_b.length; i++) { if (collection_a.contains(collection_b[i])) { result.push(collection_b[i]); } } return result; } Array.prototype.contains = function(item){ for (var i = 0; i < this.length; i++) { if (this[i] == item) { return true; } } return false; } module.exports = get_intersection;
Array.prototype.contains = function(item) { return this.indexOf(item) === -1 ? false : true }
Array.prototype.contains = function(item) { return this.indexOf(item) > -1; };
Array.prototype.contains = function (item) { for (i in this) { if (this[i] === item) { return true; }/*w w w . j a v a 2 s. c om*/ } return false; };
Array.prototype.contains = function (item) { var i = 0;/*from w ww . ja v a 2s . co m*/ for (i = 0; i < this.length; i += 1) { if (this[i] === item) { return true; } } return false; };
Array.prototype.contains = function(item) { for ( var i = 0 ; i < this.length ; i++ ) { if ( this[i] == item ) return true;/*from ww w . j a va2 s . com*/ } return false; };