admin 管理员组

文章数量: 1086019


2024年4月13日发(作者:计算机编程语言包括)

js数组中常用的方法

English Answer:

1. () Adds one or more elements to

the end of an array and returns the new length of the array.

2. () Removes the last element from

an array and returns that element.

3. () Removes the first element

from an array and returns that element.

4. t() Adds one or more elements

to the beginning of an array and returns the new length of

the array.

5. () Creates a new array

containing a copy of a specified portion of the original

array.

6. () Adds or removes elements

from an array at a specified position, and returns the

removed elements.

7. () Combines two or more arrays

into a new array.

8. () Concatenates the elements of

an array into a string.

9. f() Returns the first index of

a specified element in an array, or -1 if the element does

not exist.

10. dexOf() Returns the last

index of a specified element in an array, or -1 if the

element does not exist.

中文回答:

1. () 将一个或多个元素添加到数组末

尾,并返回数组的新长度。

2. () 从数组中移除最后一个元素并返回

该元素。

3. () 从数组中移除第一个元素并返回

该元素。

4. t() 将一个或多个元素添加到数组

开头,并返回数组的新长度。

5. () 创建一个新数组,包含原始数组

指定部分的副本。

6. () 在指定位置添加或移除数组中

的元素,并返回已移除的元素。

7. () 将两个或多个数组合并到一个

新数组中。

8. () 将数组中的元素连接成一个字符

串。

9. f() 返回数组中指定元素的第一个

索引,如果元素不存在则返回 -1。

10. dexOf() 返回数组中指定元素的

最后一个索引,如果元素不存在则返回 -1。


本文标签: 数组 元素 返回