Fork me on GitHub

Coding Poineer

Coding Poineer

Coding Poineer

Coding Poineer

Coding Poineer

Coding Poineer

Coding Poineer

Coding Poineer

Coding Poineer

Coding Poineer

Coding Poineer

JS Array API梳理

------------------------返回迭代对象--------------------------

concat: array.entries() --->返回一个迭代对象(value包含:key+值)

keys: array.keys() --->返回包含下标的迭代对象

------------------------返回新数组--------------------------

fill: array.fill(value, 【start|0】, 【end|length】) --->新数组

filter: array.filter(function(currentValue,【index,arr】), 【thisValue】) --->新数组

from: Array.from(object 含length|迭代对象,【mapFunction, thisValue】) --->返回新数组

map: array.map(function(currentValue,【index,arr), thisValue】) --->返回新数组

from: Array.from(object 含length|迭代对象, mapFunction, thisValue) --->返回新数组

concat: array1.concat(array2,array3,...,arrayX) 参数:任意值 && 任意数量 --->返回一个新数组

forEach: array.forEach(function(currentValue,【index,arr】), 【thisValue】) --->每个元素执行一次callBack函数

------------------------查询/筛选判断 返回Boolean--------------------------

find: array.find(function(currentValue,【index,arr】), 【thisValue】) --->返回数组中符合条件的第一个值 | undefined

findIndex: array.findIndex(function(currentValue,【index,arr】), 【thisValue】) --->返回数组中符合条件的第一个index | undefined

every: array.every(function(currentValue,【index,arr】), 【thisValue|undefined】) --->所有元素满足则输出true

includes: arr.includes(searchElement,【fromIndex|0】) --->返回 true|false

indexOf: array.indexOf(item,【start|0】) findIndex可以选择函数--->返回 true|false

isArray: Array.isArray(obj) --->返回true | false

some: array.some(function(currentValue,【index,arr),thisValue】) --->碰到满足条件的返回true

------------------------字符串--------------------------

join: array.join(separator) --->返回 字符串

toString: array.toString() 数组所有值用逗号隔开

------------------------增删--------------------------

pop: array.pop() --->返回删除的元素

push: array.push(item1, item2, ..., itemX) --->返回新数组的length

shift: array.shift() 删除第一个元素--->返回删除元素

splice: array.splice(index删除/添加位置,【num数量】,【item1,.....,itemX要添加的元素】) 添加或删除--->删除返回删除元素

unshift: array.unshift() 在头部加入元素--->返回新数组的length

------------------------结构变化--------------------------

reverse: array.reverse() --->返回颠倒顺序后的数组(改变原数组)

reduce: array.reduce(function(prev, currentValue,【currentIndex, arr), initialValue】) --->返回数组相加后的总和

sort: array.sort(sortfunction) 数组排序--->返回数组引用

posted @ 2021-01-28 14:45  365/24/60  阅读(103)  评论(0编辑  收藏  举报