js去空格和检测值在数组中是否存在

        Array.prototype.in_array = function(val){
            for(var i=0;i<this.length;i++){
                if(val == this[i]){
                    return true;
                }
            }
            return false;
        }

        String.prototype.trim = function() {
            return this.replace(/^\s+|\s+$/g, '');
        }

 

posted @ 2014-07-30 10:55  wh-王东  阅读(311)  评论(0)    收藏  举报