Javascript Array containsString(str)

Description

Javascript Array containsString(str)


Array.prototype.containsString = function(str) {
    //from w ww  . j ava 2 s .  c o m
    if(str && typeof str == 'string'){
        for (i = 0; i < this.length; i++) {
            if(this[i] && this[i] === str){
                return true;
            }  
        }
    } else{
        throw "Invalid Argument";
    }
    return false;
};



PreviousNext

Related