1.創(chuàng)建一個空對象作為this
2.this.proto指向構(gòu)造函數(shù)的prototype
3.運(yùn)行構(gòu)造函數(shù)
4.返回this(如果函數(shù)沒有return)
new相當(dāng)于語法糖,幫我們完成了這些創(chuàng)建實(shí)例所要操作的步驟。
1.創(chuàng)建一個空對象作為this
2.this.proto指向構(gòu)造函數(shù)的prototype
3.運(yùn)行構(gòu)造函數(shù)
4.返回this(如果函數(shù)沒有return)
new相當(dāng)于語法糖,幫我們完成了這些創(chuàng)建實(shí)例所要操作的步驟。