- Increase::
push(item1, item2...)
Insert […, item1, item2… ] at the end
unshift(item1, item2, ...)
: Insert [ item1, item2… , …] at the beginning
splice(startIndex, ?deleteCount, item1, item2...)
: Any position
concat(?item, ?Array)
: Insert at the end, return array copy - Delete::
pop()
Delete the last element of the array, and return
shift()
: Delete the first element of the array, and return
slice(startIndex, ?endIndex)
: Delete the specified area element
splice(startIndex, ?deleteCount)
: Delete the specified number of elements at the beginning of the specified area, and return the deleted elements in the form of a list. When deleteCount is greater than the remaining elements, the elements before startIndex are retained. - change
splice(startIndex, ?deleteCount, item1, item2...)
- Check
[index]
: Out of bounds returnundefine
indexOf(item, ?startIndex)
: search from the beginning, return -1 if not found
lastIndexOf(item, ?startIndex)
: search from the end, return -1 if not found - Traversal
for循环
for(let item of array) { }
: normal responsecontinue
,break
,return
, Item can not modify the original array
forEach( (item, index) => { } )
: can not respondcontinue
,break
,return
, Item can not modify the original array - Some commonly used methods
map((value, index, array)=>{})
filter((value, index, array)=>{})
reduce((pre, curr, index, array)=>{}, initValue)
reduceRight((pre, curr, index, array)=>{}, initValue)
find((value, index, array)=>{ return 布尔值 })
findIndex((value, index, array)=>{ return 布尔值 })
keys()
,values()
,entries()
: Return iterator object
Adding, deleting, modifying, checking, traversing and common methods of javascript array
Guess you like
Origin blog.csdn.net/SJ1551/article/details/109295038
Recommended
Ranking