Array Contains Example

Sabarimahesh
Posted by Sabarimahesh under JavaScript category on | Points: 40 | Views : 988
Array.prototype.contains = function (ele) {
for (var i = 0; i < this.length; i++) {
if (this[i] == ele) {
return true;
}
}
return false;
}
Array1 = ["1", "2", "3"];
document.write(" Cont Of "+Array1.contains("2")+"<br>");

Comments or Responses

Login to post response