判断某值是否在该数组中


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

var arr = [1,2,3,4,5]
arr.in_array(5) //true

猜你喜欢

转载自blog.csdn.net/supertree_l/article/details/83537618
今日推荐