可以自己写一个
Array.prototype.append = function(str) {
var newArr = new Array(str);
return this.concat(newArr);
}Array.prototype.remove = function(str) {
var retArr = new Array();
for(i = 0; i < this.length; i++) {
if(this[i] != str) retArr = retArr.append(this[i]);
}
return retArr;
}Array.prototype.hasItem = function(str) {
for(var i = 0; i < this.length; i++) {
if(this[i] == str) {
return true;
}
}
return false;
}
Array.prototype.append = function(str) {
var newArr = new Array(str);
return this.concat(newArr);
}Array.prototype.remove = function(str) {
var retArr = new Array();
for(i = 0; i < this.length; i++) {
if(this[i] != str) retArr = retArr.append(this[i]);
}
return retArr;
}Array.prototype.hasItem = function(str) {
for(var i = 0; i < this.length; i++) {
if(this[i] == str) {
return true;
}
}
return false;
}
解决方案 »
- 为什么这个JavaScript脚本不运行函数体啊??
- 请教如何使用javascript调用本地程序并打印出输出?
- 我想拿到下拉框中所有的name,也就是一个页面有多少个select就拿到多少的select <select id=""><option>list</option></select>
- 请教如何给用insertCell插入的表单元绑定事件句柄
- 哪儿错了?
- 如何限制用户输入的是数字 且输入的数字大小<=100
- help:如何向父窗口中的控件赋值?
- open窗口的难题!?
- 急求javascript中定义用户对象和结构体的语法
- 有一表单,有八个输入框,名字为(a-h),一个隐藏框名字为(i),提交至下一页,如何让隐藏框
- javascript疑问
- 关于$的问题
方法概览
concat Joins two arrays and returns a new array.
join Joins all elements of an array into a string.
pop Removes the last element from an array and returns that element.
push Adds one or more elements to the end of an array and returns that last element added.
reverse Transposes the elements of an array: the first array element becomes the last and the last becomes the first.
shift Removes the first element from an array and returns that element
slice Extracts a section of an array and returns a new array.
splice Adds and/or removes elements from an array.
sort Sorts the elements of an array.
toString Returns a string representing the specified object.
unshift Adds one or more elements to the front of an array and returns the new length of the array.