function OperateArray(array) {
this.array = array;
}
OperateArray.prototype.hasValue = function(val) {
for (var i = 0; i < this.array.length; i++) {
if (this.array[i] == val) {
return i;
}
}
return -1;
}
OperateArray.prototype.removeValue = function(val) {
var index = this.array.indexOf(val);
if (index > -1) {
this.array.splice(index, 1);
return this.array;
}
}
var arr = [1, 2, 3, 4, 5];
var arrcz = new OperateArray(arr);
arrcz.hasValue(4);//判断是否有数组 大于0:含有 返回数组的下标
if (arrcz.hasValue(4) > 0) {
var resultArr=arrcz.removeValue(4);//删除数组
console.log(resultArr)
}