Last active
August 29, 2015 14:12
-
-
Save think2011/9f12524edc1bda68845e to your computer and use it in GitHub Desktop.
new constructor的过程
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
1. 创建一个新的对象,这个对象的类型是object。 | |
2. 该对象的prototype设置为构造器的prototype属性,即this.prototype = Foo.prototype (伪代码) | |
3. 执行构造器函数。 | |
4. 如果构造器函数有返回值,则以该对象作为返回值。若没有return或return了基本类型,则将上述的新对象作为返回值。 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment