JS prototype constructor转载之四

来源:互联网 发布:尼特消防主机怎么编程 编辑:程序博客网 时间:2024/06/07 03:38

js constructor属性


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

原创粉丝点击