js constructor属性

来源:互联网 发布:阿里云邮箱电脑版下载 编辑:程序博客网 时间:2024/05/19 17:51

constructor属性返回对创建此对象的数组函数的引用。

语法:object.constructor

<script type="text/javascript">

var test=new Array();

if(test.constructor==Array)

{

  document.write("this is an array");

}

if(test.constructor==Boolen)

{

  document.write("this is a Boolen");

}

if(test.constructor==String)

{

document.write("this is a string");

}

</script>

 

输出:

This is an Array