๐ธprototype
function's `prototype` property.
Last updated
function's `prototype` property.
Last updated
JS โฉ value โฉ object โฉ function โฉ prototype
only a relatively small number of objects have a "prototype" property, it's these objects that define the prototypes for all the other objects.
function's prototype (property)
is (only) used as a new object's prototype.
should be either an object or null, other values wonโt workโ
๐ javascript.info
โญ๏ธ every function has a default prototype. (with the only constructor property that points back to the function itself)
if A.prototype
is an object, then let a = new A()
will set a.__proto__ = A.prototype
.
โญ๏ธ ๆณจๆ๏ผ
ๅฆๆๆนๅฏซๅฝๆธ็ prototype๏ผๅฆ๏ผA.prototype = {}
๏ผๅๅพๅพ็ new A() ็ฉไปถๅฐฑๅไนๆฒๆ constructor ๅฑฌๆง๏ผ้ค้ไฝ ่ชๅทฑๅจๆฐ็ prototype ไธญๅๅ ๅ
ฅ constructor ๅฑฌๆงโ๏ธ(่็็ฉไปถๆฒๆๅฝฑ้ฟ๏ผๅ ็บ่็ prototype ไพ็ถๅญๅจ๏ผ่็็ฉไปถ็ [[Prototype]]
ๅฑฌๆงๆฒๆๆน่ฎ๏ผไพ็ถๆๅ่็ prototype)