Javascript Array containsObject(obj)
Array.prototype.containsObject = function(obj){ var i;/*from ww w .jav a 2 s . c o m*/ for (i = 0; i < this.length; i++) { if (this[i] === obj) { return true; } } return false; };
Array.prototype.containsObject = function (obj) { var contains = false; for (var i = 0; i < this.length; i++) { if (this[i] == obj) { contains = true;/* w w w . ja v a 2 s . c o m*/ } } return contains; };
Array.prototype.containsObject = function(obj) { return this.filter(item => item === obj).length !== 0; }