We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
new关键字与构造函数一起使用以创建对象:
new
function Employee(name, position, yearHired) { this.name = name; this.position = position; this.yearHired = yearHired; }; const emp = new Employee("Marko Polo", "Software Developer", 2017);
new关键字做了4件事:
4
{}
this
**proto**
prototype
return
看下面事例:
function Person() { this.name = '前端小智' }
根据上面描述的,new Person()做了:
new Person()
var obj = {}
**proto__
this.__proto** = Person().prototype
return this
new操作符具体干了什么呢? #36
The text was updated successfully, but these errors were encountered:
No branches or pull requests
new
关键字与构造函数一起使用以创建对象:new
关键字做了4
件事:{}
this
值**proto**
指向构造函数的prototype
return
语句,则返回this
看下面事例:
function Person() { this.name = '前端小智' }
根据上面描述的,
new Person()
做了:var obj = {}
this
值:this = obj**proto__
指向构造函数的prototype
:this.__proto** = Person().prototype
this
:return this
new操作符具体干了什么呢? #36
The text was updated successfully, but these errors were encountered: