javascript change array length methods
Array
- 改变数组长度的方法
push, pop
shift, unshift,
splice,
fill,
- 不改变数组长度的方法
map, forEach,
filter,
reduce, reduceRight,
some, every,
indexOf, lastIndexOf,
sort, reverse,
join,
includes,
concat,
entries, keys, values,
toString, toLocaleString,
find, findIndex,
flat
flatMap
copyWithin,
Array.from
Array.of
Array.isArray
Array.fill 改变数组长度 ❌
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/fill
// fill 填充
arr.fill(value[, start[, end]])
Array.splice 改变数组长度 ❌
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/splice
// splice 拼接
let arrDeletedItems = array.splice(start[, deleteCount[, item1[, item2[, ...]]]])
Array.slice 不改变数组长度 ✅
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/slice
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/slice
// slice 切片
// string.slice(beginIndex[, endIndex])
array.slice([start[, end]])
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/concat
refs
https://javascript.info/array-methods
©xgqfrms 2012-2020
www.cnblogs.com 发布文章使用:只允许注册用户才可以访问!