Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ES5/ES6 类的区别 #12

Open
nmsn opened this issue Jun 3, 2022 · 0 comments
Open

ES5/ES6 类的区别 #12

nmsn opened this issue Jun 3, 2022 · 0 comments

Comments

@nmsn
Copy link
Owner

nmsn commented Jun 3, 2022

来源:Advanced-Frontend/Daily-Interview-Question#20

  1. class 会进行声明提升,类似 let const,进入暂时性死区
  2. class 内部采用严格模式
  3. class 所有方法(包括静态和实例方法)都是不可枚举的
  4. class 的所有方法(包括静态方法和实例方法)都没有原型对象 prototype,所以也没有 [[construct]],不能使用 new 来调用
  5. 必须使用 new 调用 class
  6. class 内部无法重写类名
  7. ES5 和 ES6 子类 this 生成顺序不同。ES5 的继承先生成了子类实例,再调用父类的构造函数修饰子类实例,ES6 的继承先生成父类实例,再调用子类的构造函数修饰父类实例。这个差别使得 ES6 可以继承内置对象
  8. ES5 原型链子类 __proto__ 指向 Function.prototype,ES6 子类 __proto__ 指向父类
@nmsn nmsn changed the title ES5/ES6 的区别 ES5/ES6 类的区别 Jun 3, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant