1. let const 有暂存死区,块级作用域内不能提升作用域 let a=1 a是不会挂载到window的
2. 新数据类型 Symbol 创建唯一值 不可以被for in 迭代
3. ... 扩展运算符 解构赋值 模板字符串
4. new Set集合 可以根据filter 去重 实现并集 交集 差集
5. new Map 类似对象去 键值对的集合 任何key new WeakMap的key必须是对象类型
6. 箭头函数 里面没this和argument会向上级作用域查找 argument找不到就报错
7. 新数据类型 Symbol 创建唯一值 不可以被for in 迭代
8. BigInt
9. new Proxy 可以对数组和对象劫持 配合 反射Reflect.get set方法读取值(因为在Proxy内通过push和pop修改数组会有问题,所以要通过Reflect)
10. 数组es6方法 find findIndex includes flat
11. es6类 es5构造函数
- 每一个类的实例都有__proto__隐式原型 ,指向其所有类的原型对象prototype 构造函数.proto === Function.prototype
- 实例.constructor === 类
- 实例.proto.proto === Object.prototype
- Object.prototype.proto === null
function Fn () {}
Fn.prototype.__poroto__ === Function.prototype
Fn.prototype.__poroto__ = Parent.prototype
Object.setPropertyOf(Fn.prototype, Parent.prototype)
const f = new Fn()
12. 使用reduce 实现redux的compose 合并中间接传参
const add = (a, b) => a + b;
const toUpper = (str) => str.toUpperCase();
const joinStr = (str) => `**${str}**`;
const getLen = (str) => str.length;
function compose(...funcs) {
return funcs.reduce((a, b) => {
return (...args) => {
return a(b(...args));
};
});
}
14. Number.isNaN 判断NaN Number.isInteger 判断整数
15. Object新方法
- Object.is 判断值是否相等
- Object.create values entries getOwnproperties keys
- Object.assgin 合并对象
- Object.setPropertyOf修改原型
17. String.trimStart trimEnd 去除左边\右边空格
18. import export es6模块导入导出
19. 可选连操作符?.
20. Promise.allSettled == all 但是allSettled不管成功或者失败都会返回
21. Promise async await
22. 装饰器用来修饰类、类的属性、类的方法 @xxxx function xxxx() {} 比如mbxo用到了
function readonly(target,property,descriptor) {
}
function flag (constructor) {
}
@flag
@second
class Animal {
@readonly
name = "sky"
}
23. 生成器generator 生成器是GeneratorFunction的实例,返回一个迭代对象调用next方法控制函数体中的代码一步一步执行
function* foo (name) {
console.log("第一段子");
const haha = yield 111
console.log(haha, "第二段");
const haha2 = yield 222
console.log(haha2, "第三段");
return
}
const gen = foo("sky")
const res= gen.next()
const res2= gen.next("haha")
const res3= gen.next("haha2")
console.log(res, "res");
console.log(res2 ,"res2");
console.log(res3 ,"res3");
24. 迭代器iterator是一种接口机制,任何数据结构只要部署iterator接口就可以实现遍历操作
Object.prototype[Symbol.iterator] = function () {
let self = this;
let index = 0;
const keys = Reflect.ownKeys(this)
return {
next() {
if (index >= keys.length) {
return {
done: true,
value: undefined
};
}
return {
done: false,
value: self[keys[index++]],
};
},
};
}