JavaScript数组对象的一些常用方法
本篇文章分成两个部分,下面是内容概览。
arr.forEach(callback[, thisArg]) 为数组中的每个元素执行指定操作
arr.slice([begin[, end]]) 返回一个shallow copy of a portion of an array新数组
arr.splice([start, deletecount[, item[, item[, ...]]]]) 修改现有数组
arr.join([separator = ',']) joins all elements of an array into a string.
var new_array = arr.concat(value1[, value2[,...]]) 组合成为新数组
arr.unshift([elem1[, ...[, elemN]]]) add the elements to the front of the array.
arr.shift() removes the first element from an array and returns that element
arr.push(elem1[], elem2, elem3) The elements to add to the end of the array.
arr.pop() removes the last element from an array and returns that value to the caller
arr.filter(callback[, thisArg])
根据条件进行数组中每个元素的过滤
arr.map(callback[, thisArg])
根据条件进行数组中每个元素的处理
arr.reduce(callback[, initialValue])
遍历数组,每一个元素累加(从左向右),最终变成为一个值
arr.reduceRight(callback[, initialValue])
遍历数组,每一个元素累加(从右向左),最终变成为一个值
arr.some(callback[, thisArg]) Array.prototype.some()
tests whether some element in the array passes the test implemented by the provided function
arr.every(callback[, thisArg]) Array.prototype.every()
tests whether all elements element in the array passes the test implemented by the provided function
arr.reverse()
reverses an array in place
(完)
浙公网安备 33010602011771号