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

2021/02/05 - Object.create() #47

Open
lxinr opened this issue Feb 5, 2021 · 0 comments
Open

2021/02/05 - Object.create() #47

lxinr opened this issue Feb 5, 2021 · 0 comments
Labels

Comments

@lxinr
Copy link
Owner

lxinr commented Feb 5, 2021

不会继承对象原型链上的属性

  1. 可以得到一个非常干净且高度可定制的对象当作数据字典
  2. 可以节省hasOwnProperty带来的一点点性能损失

Object.create()、new Object()和{}的区别

  1. 字面量和new关键字创建的对象是Object的实例,原型指向Object.prototype,继承内置对象Object
  2. Object.create(arg, pro)创建的对象的原型取决于argargnull,新对象是空对象,没有原型,不继承任何对象;arg为指定对象,新对象的原型指向指定对象,继承指定对象
@lxinr lxinr added the JS基础 label Feb 5, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant