Javascript Array contains(o)
Array.prototype.contains = function(o) { for (var i = 0; i < this.length; i++) { if (this[i] == o) { return true;/*from w w w . jav a 2 s .co m*/ } } return false; } function getContextPath() { var pathName = document.location.pathname; var index = pathName.substr(1).indexOf("/"); var result = pathName.substr(0,index+1); return result; }
/**//from w ww .j a va2 s . c o m * judge the target in Array * * @param o the target * @returns {Boolean} */ Array.prototype.contains = function(o) { var flag = false; for (var i = 0; i < this.length; i++) { if (this[i] == o) { flag = true; break; } } return flag; };