英 [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>运行实例 »
点击 "运行实例" 按钮查看在线实例