I am a Developer, Blogger and Coffee addict. Java developer by profession, Q2A developer by addiction. This is my personal website where I write few stuff which could be useful for other developers.
© 2020. All rights reserved.
The below function can efficiently check whether an element exists in the array or not
if (!Array.prototype.elemetExists) { Array.prototype.elemetExists = function (string) { return !!~this.indexOf(string); }; } //usage var fruits = ['Apple' , 'Banana' , 'Orange' , 'Mango']; console.log(fruits.elemetExists('Banana')); //true console.log(fruits.elemetExists('Lichi')); //false