英 [kənˈstrʌktə(r)] 美 [kən'strʌktə]
n.构造器
复数: constructors
javascript constructor属性 语法
constructor属性是什么意思?
constructor存在于每一个function的prototype属性中,constructor属性是返回对创建此对象的数组函数的引用。
作用:返回对创建此对象的数组函数的引用。
语法:object.constructor
说明:constructor 属性返回对创建此对象的数组函数的引用。
注释:无
javascript constructor属性 示例
<html>
<body>
<script type="text/javascript">
var test=new Array();
if (test.constructor==Array)
{
document.write("This is an Array");
}
if (test.constructor==Boolean)
{
document.write("This is a Boolean");
}
if (test.constructor==Date)
{
document.write("This is a Date");
}
if (test.constructor==String)
{
document.write("This is a String");
}
</script>
</body>
</html>运行实例 »
点击 "运行实例" 按钮查看在线实例
热门推荐
- Dapper如何映射到私有构造函数的类 Dapper private constructor映射
- c++中的delegating constructor是什么_构造函数委托的语法与应用场景
- C++编译错误"expected constructor, destructor, or type conversion"怎么办?
- java中的constructor是什么 构造函数的4个关键特性
- PHP 8的Constructor Property Promotion是什么
- 为什么 React 18 类组件在严格模式下,模拟渲染的 constructor 会先于首次渲染的 componentDidMount 执行?