c68ychen

导航

 

JavaScript constructor 属性

定义和用法 constructor 属性返回对创建此对象的 Boolean 函数的引用。

语法

object.constructor

实例

如何使用 constructor 属性:

<script type="text/javascript">

var test=new Boolean();

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>

  输出:

This is a Boolean

  

posted on 2020-10-28 22:13  c68ychen  阅读(311)  评论(0)    收藏  举报