constructor

创建于 2024-12-03 / 39
字体: [默认] [大] [更大]
上一节 JavaScript 字符串参考 下一节

实例

constructor 构造函数属性返回字符串的构造函数:

var str = "Hello World!"; 亲自试一试 »

定义和用法

在 JavaScript 中,constructor 属性返回对象的构造函数。

返回值是对函数的引用,而不是函数的名称:

对于 JavaScript numbers 构造函数属性返回函数 function Number() { [native code] }

对于 JavaScript strings 构造函数属性返回函数 function String() { [native code] }

对于 JavaScript booleans 构造函数属性返回函数 function Boolean() { [native code] }


浏览器支持

属性
constructor Yes Yes Yes Yes Yes

语法

string.constructor

技术细节

返回值: function String() { [native code] }
JavaScript 版本: 1.1

上一节 JavaScript 字符串参考 下一节
0 人点赞过