码迷,mamicode.com
首页 > 编程语言 > 详细

javascript Array对象的constructor属性

时间:2015-01-09 22:21:04      阅读:479      评论:0      收藏:0      [点我收藏+]

标签:

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

语法
object.constructor

例子:

<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>

打印:

This is an ArrayTIY

第二个例子:

<script type="text/javascript">

function employee(name,job,born)
{
this.name=name;
this.job=job;
this.born=born;
}

var bill=new employee("Bill Gates","Engineer",1985);

document.write(bill.constructor);

</script>

打印:

function employee(name, jobtitle, born)
{this.name = name; this.jobtitle = job; this.born = born;}

javascript Array对象的constructor属性

标签:

原文地址:http://blog.csdn.net/helloboat/article/details/42563283

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!