FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
dataStructure-about-JS/API/Array.md at master · liiiier/dataStructure-about-JS · GitHub
liiiier
/
dataStructure-about-JS
Public
Notifications
You must be signed in to change notification settings
Fork
0
Star
0
Code
Issues
0
Pull requests
0
Actions
Projects
Security and quality
0
Insights
Additional navigation options
Code
Issues
Pull requests
Actions
Projects
Security and quality
Insights
Expand file tree
Breadcrumbs
dataStructure-about-JS
/
API
/
Array.md
Copy path
More file actions
More file actions
Latest commit
History
History
History
22 lines (21 loc) · 2.35 KB
Breadcrumbs
dataStructure-about-JS
/
API
/
Array.md
Copy path
File metadata and controls
22 lines (21 loc) · 2.35 KB
Raw
Copy raw file
Download raw file
Edit and raw actions
#JS储存数据之 array
Array.length 返回数组长度 2.Array.from() 方法从一个
类似数组
或可迭代对象中创建一个新的数组实例。传入类似数组对象及map回调方法,返回新数组。 3.fill() 方法用一个固定值填充一个数组中从起始索引到终止索引内的全部元素。返回修改后的数组(原数组)。 5.forEach() 方法对数组的每个元素执行一次提供的函数。 6.reduce() 方法对累加器和数组中的每个元素(从左到右)应用一个函数,将其减少为单个值。 7.includes() 方法用来判断一个数组是否包含一个指定的值,根据情况,如果包含则返回 true,否则返回false。 8.join() 方法将一个数组(或一个类数组对象)的所有元素连接成一个字符串并返回这个字符串。 9.keys() 方法返回一个新的Array迭代器,它包含数组中每个索引的键。 10.map() 方法创建一个新数组,其结果是该数组中的每个元素都调用一个提供的函数后返回的结果。 数组操作: 11.concat() 方法用于合并两个或多个数组。此方法
不会更改
现有数组,而是返回一个新数组。 12.pop() 方法从数组中删除最后一个元素,并返回该元素的值。此方法更改数组的长度。 13.push() 方法将一个或多个元素添加到数组的末尾,并返回新数组的长度。 14.shift() 方法从数组中删除第一个元素,并返回该元素的值。此方法更改数组的长度。 15.unshift() 方法将一个或多个元素添加到数组的开头,并返回新数组的长度。 16.reverse() 方法将数组中元素的位置颠倒。 17.sort() 方法用就地( in-place )的算法对数组的元素进行排序,并返回数组。 sort 排序不一定是稳定的。默认排序顺序是根据字符串Unicode码点。会改变原数组,返回排序后的数组。 18.splice() 方法通过删除现有元素和/或添加新元素来更改一个数组的内容。可以用于删除也可用于插入数据。返回被删除的元素(集合)。 19.slice() 方法返回一个从开始到结束(不包括结束)选择的数组的一部分浅拷贝到一个新数组对象。且原始数组不会被修改。截取内容的范围是
start <= val < end
。可以使用 arr.slice() 对数组进行浅拷贝。
Back
|
FazBrowse Home
|
New Git URL