[英]What is the default value of internal [[prototype]] property in JavaScript?
[英]In JavaScript, what is the default value of a function's prototype property?
在Chrome的JavaScript控制台中:
function placeOrder() {
return 1;
};
undefined
console.log(placeOrder.prototype);
placeOrder {}
但在IE 11中,默認的prototype屬性似乎是一個空對象。 我想知道Chrome中的對象“placeOrder {}”是什么? 我也在Firefox中測試過它。 在Firefox中,prototype屬性也是“placeOrder {}”。
在IE 11控制台中:
function placeOrder() {
return 1;
};
undefined
console.log(placeOrder.prototype);
undefined
[object Object]{}
謝謝。
它是一個繼承自Object.prototype
的對象,它有一個自己的constructor
屬性,其值是構造函數。
請參見創建函數對象
- 讓proto成為創建一個新對象的結果,該對象將由表達式
new Object()
構造,其中Object
是具有該名稱的標准內置構造函數。- 使用參數
"constructor"
調用proto的[[DefineOwnProperty]]內部方法, 屬性描述符 {[[Value]]: F ,{[[Writable]]: true ,[[Enumerable]]: false ,[[Configurable]] : true }, false 。- 使用參數
"prototype"
調用F的[[DefineOwnProperty]]內部方法, 屬性描述符 {[[Value]]: proto ,{[[Writable]]: true ,[[Enumerable]]: false ,[[Configurable]] : false }, false 。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.