Skip to content

Update understand-prototype-__proto__.md #10

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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions points/understand-prototype-__proto__.md
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@
![2](http://angular.angular-china.org/cbe213bb-6f1e-4fc5-84d4-fa082bf50a89.jpg)
+ 接下来`var car = new Car('porsche')`这一行代码可不像它看起来那样,它内部的实现还是有许多值得玩味的;
首先,函数`Car`创建了一个新的对象(a),**这个对象有一个隐藏的属性`__proto__`,这个属性和`Car`的原型都指向同一个对象.**
然后`Car`函数内部的`this`指向哪个新创建的对象(a).如下图所示:
然后`Car`函数内部的`this`指向那个新创建的对象(a).如下图所示:
![3](http://angular.angular-china.org/6441a0ee-2acd-4667-82b7-8d8a7b57f188.jpg)
+ 然后我们给这个对象添加了一个属性`name`,并且为其赋值.**还要注意的一点是,我们这个`Car`函数是有返回值的,虽然没有使用`return`关键字
把这个值显式的返回**,这个返回值是一个引用,然后变量`car`就可以用来操作那个对象了(a).
Expand Down Expand Up @@ -147,4 +147,4 @@



[1]:http://pythontutor.com/visualize.html#code=console.log%28%7B%7D.__proto__%29;%0Aconsole.log%28%28function%28%29%7B%7D%29.prototype%29;&mode=display&origin=opt-frontend.js&cumulative=false&heapPrimitives=false&textReferences=false&py=js&rawInputLstJSON=%5B%5D&curInstr=2
[1]:http://pythontutor.com/visualize.html#code=console.log%28%7B%7D.__proto__%29;%0Aconsole.log%28%28function%28%29%7B%7D%29.prototype%29;&mode=display&origin=opt-frontend.js&cumulative=false&heapPrimitives=false&textReferences=false&py=js&rawInputLstJSON=%5B%5D&curInstr=2