![](https://img.laitimes.com/img/9ZDMuAjOiMmIsIjOiQnIsIiZpdmLwV3LcNXZnFWbp9CXt92YuI2bv5Wdy5yd3d3Lc9CX6MHc0RHaiojIsJye.gif)
JavaScript 數組對象
傳回fruits數組對象原型建立的函數:
fruits.constructor;
結果輸出:
function Array() { [native code] }
在 JavaScript 中, constructor 屬性傳回對象的構造函數。
傳回值是函數的引用,不是函數名:
JavaScript 數組 constructor 屬性傳回 function Array() { [native code] }
JavaScript 數字 constructor 屬性傳回 function Number() { [native code] }
JavaScript 字元串 constructor 屬性傳回 function String() { [native code] }
如果一個變量是數組你可以使用 constructor 屬性來定義。
屬性
constructor
Yes
所有主流浏覽器都支援 constructor 屬性。
array.constructor
傳回值:
一個函數對象。該函數由數組對象的原始建立。
JavaScript 版本:
1.1
![](https://img.laitimes.com/img/9ZDMuAjOiMmIsIjOiQnIsIiZpdmLwV3LcNXZnFWbp9CXt92YuI2bv5Wdy5yd3d3Lc9CX6MHc0RHaiojIsJye.gif)