javascript 原型鏈觀察

峰Caesar
峰Caesar
Aug 31, 2018 · 1 min read

主要重點

1.利用new創造的物件, 只得到建構函式中的特性。

2.參考型別的特性,不會追蹤原型鏈,新增特性到自己的物件。

3.為了解決上述原因,請了解 call by sharing,從新給予新的物件。Ref.[2]

4. 在為物件添加屬性時,只會覆蓋其建構函式的原型對象中的同名屬性,這種情況叫做“屬性屏蔽”,原型對象中的屬性是不會被修改的!無論這個屬性是基本類型還是引用類型。

5. 一般来说,我们不能把数组或纯对象的数据放到原型中

Ref:

[1] JS面向对象的模式与实践

[2]深入探討 JavaScript 中的參數傳遞:call by value 還是 reference?

Caesar's study review on Web development

軟體web開發的學習心得

峰Caesar

Written by

峰Caesar

我的第一份後端工作結束了,短短四個月,部門全員掰掰,尋找新的機會。

Caesar's study review on Web development

軟體web開發的學習心得

Welcome to a place where words matter. On Medium, smart voices and original ideas take center stage - with no ads in sight. Watch
Follow all the topics you care about, and we’ll deliver the best stories for you to your homepage and inbox. Explore
Get unlimited access to the best stories on Medium — and support writers while you’re at it. Just $5/month. Upgrade