hawtim.github.io
hawtim.github.io copied to clipboard
常用的数组方法总结
判断数组类型
- Object.prototype.toString.call([]) === '[object Array]'
- Array.isArray
转换类数组
- Array.from
- Array.prototype.slice.call(arguments)
数组方法
-
push/pop 为一组
-
shift/unshift 为一组
-
some/every 为一组
-
map/filter 为一组
-
includes/find/findIndex为一组
-
slice/splice为一组
-
concat/join为一组
-
from/isArray 为一组
-
indexOf/lastIndexOf 为一组
-
reduce 单独一组,对数组中每个元素升序执行 reducer 函数,将结果汇总到累加器中最终返回
- accumulator
- currentValue
- currentIndex
- sourceArray
Mindmap attachment:
