(syntax)es6
2022-09-01 00:00:00
es6
es6
- es6 js的下一代标准、ES2018(ES6第四个版本)、「ES8(实质上是ES2017) 不规范的概念」
- let 变量 const 常量(大写) var
- 全局 var 、函数 function、块级 let
- TDZ
- 解构赋值
- 字符串解构 let [a,b,c] = “VCD” let {length:len} = “FBI”
- 数值和布尔解构 数值和布尔值会先转为对象 let {toString:s} = 124/true let {prop:x} = undefined/null
- 对象结构 const { x, y = 2 } = { x: 1 } 改名:const { x, y: z } = { x: 1, y: 2 }
- 数组结构 let [a=300,b,c] =[,200,300]
- 函数参数解构 function A([]) function B({})
- 扩展
- 字符串
- 扩展
- 模板字符串
- 方法
- js
- charAt charCodeAt codePointAt localeCompare
- search slice split sub substr substring
- toLocaleLowerCase toLocaleUpperCase toLocaleCase toUpperCase toString valueOf
- String.raw 格式化转义字符
- 实例方法
- normalize Unicode 正规化
- indexOf 字符串首次出现的位置 { includes startsWith endsWith 包含 返回布尔值 }
- repeat 重复
- padStart(补全长度,补全字符串) padEnd 补全长度
- 123456’.padStart(10, ‘0’) // “0000123456”
- ‘01-30’.padStart(10, ‘YYYY-MM-DD’) // “YYYY-01-30”
- trimStart trimEnd 去除空格 trimRIght trimLeft trimLeft()是trimStart()的别名,trimRight()是trimEnd()
- matchAll 返回所有匹配的 replaceAll 替换所有匹配 replace 替换一个
- at 负索引 at[-1]
- js
- 扩展
- 正则
- 数值
- 函数
- 数组
- Array.
- from 将类数组转化成数组
- of 创建数组(10,23,90)/弥补Array(3)和new Array()的不足
- Array.prototype.
- copyWithin 把指定位置的成员复制到其他位置,返回原数组
- find、findIndex、findLast、findLastIndex 找值和键
- fill 填充数组
- entries、keys、values 遍历数组
- include
- flat、flatMap
- at
- group、groupToMp (提案) 数组成员分组
- 数组的空位
- sort
- reduce
- filter
- Array.
- 对象
- 对象的简化写法
- 运算符
指数 **
链式判断 ?.
Null判断 ??
逻辑赋值
扩展运算符
- 字符串
- 数据结构
- BigInt
- Set && Map
- Symbol
- 内置属性
- Array Buffer
- 迭代器
操作对象
:- Proxy
- Reflect
- Decorator
- 类和模块
- class 类
- module 模块
异步编程
- 回调函数和事件
- Iterator 和 for..of 循环
- async/await
- Promise
- Generator
- 异步遍历器