我的网站开发技术经验总结 我的网站开发技术经验总结
首页

fangdown

我的网站开发技术经验总结
首页
  • 大前端

  • 基础

    • js

    • css

    • ES6

      • 说说对模块化的理解
      • 说说ES6中对象新增了哪些扩展
      • 说说ES6中函数新增了哪些扩展
      • ES6中数组的常用方法
        • 是什么
        • 怎么用
          • 常用
          • 其他
        • 原理
        • FAQ
      • 说说ES6中新增的Set、Map的区别
      • 说说ES6中Decorator的理解
      • 说说ES6中Generator的应用
      • 说说ES6中Promise的常用方法及原理
      • 说说ES6中Proxy的理解
      • 说说var、let、const之间的区别
  • 框架

  • 情商

  • 算法

  • 网络

  • 千锤百炼
  • 基础
  • ES6
fangdown
2021-08-02
目录

ES6中数组的常用方法

# 是什么

ES6中新增的一些方法或者特性

# 怎么用

# 常用

  1. 扩展运算符
console.log(1, ...[2, 3, 4], 5)
// 1 2 3 4 5

[...document.querySelectorAll('div')]
// [<div>, <div>, <div>]
  1. 构造函数 Array.from() Array.of()

  2. 实例方法

  • copyWithin()
  • find()、findIndex()
  • fill()
  • entries(),keys(),values()
  • includes()
  • flat(),flatMap()
[1, 2, 3, 4, 5].copyWithin(0, 3) // 将从 3 号位直到数组结束的成员(4 和 5),复制到从 0 号位开始的位置,结果覆盖了原来的 1 和 2
// [4, 5, 3, 4, 5] 

[1, 5, 10, 15].find(function(value, index, arr) {
  return value > 9;
}) // 10

[1, 5, 10, 15].findIndex(function(value, index, arr) {
  return value > 9;
}) // 2

['a', 'b', 'c'].fill(7)
// [7, 7, 7]

for (let elem of ['a', 'b'].values()) {
  console.log(elem);
}
// 'a'
// 'b'

[1, 2, 3].includes(2)     // true

[1, 2, [3, 4]].flat()
// [1, 2, 3, 4]

# 其他

# 原理

# FAQ

#数组
上次更新: 2021/12/19, 18:05:42
说说ES6中函数新增了哪些扩展
说说ES6中新增的Set、Map的区别

← 说说ES6中函数新增了哪些扩展 说说ES6中新增的Set、Map的区别→

最近更新
01
多分支修复撞车的问题
05-01
02
如何成为架构师
01-23
03
服务器部署全过程
11-23
更多文章>
Theme by Vdoing | Copyright © 2019-2026 fangdown | 粤ICP备19079809号
  • 跟随系统
  • 浅色模式
  • 深色模式
  • 阅读模式