定义和用法

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

语法

object.constructor

实例

例子 1

在本例中,我们将展示如何使用 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 Array

TIY

例子 2

在本例中,我们将展示如何使用 constructor 属性:

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

TIY

TIY

constructor
在本例中,我们将展示如何使用 constructor 属性。

随机推荐

  1. How does java technology relate to cloud computing?

    Java Paas shootout   (@IBM developer) Cloud computing is always a hot topic around IT field today.Ho ...

  2. Learn know more about big data

    As we all know,we are in a big data age now."Every sword has two slides",as a ITer,we shou ...

  3. 用MSBuild和Jenkins搭建持续集成环境 - 转

    http://www.infoq.com/cn/articles/MSBuild-1 http://www.infoq.com/cn/articles/MSBuild-2 MSBuild是在.NET ...

  4. Highcharts-3.0.6

    Highcharts-3.0.6 报表插件

  5. Objective-C传递数据小技巧

    转自:http://www.guokr.com/blog/203413/ 比如说,如果你想向UIAlertView的delegate方法中传递一些信息,怎么办?继承UIAlertView么?使用Cat ...

  6. 使用XFire+Spring构建Web Service(一)——helloWorld篇

    转自:http://www.blogjava.net/amigoxie/archive/2007/09/26/148207.html原文出处:http://tech.it168.com/j/2007- ...

  7. WinForm点击按钮在对应的panel里画图

    panel在form1里,button在form1上方,panel在下面. 主要是在button1的click时间获取panel的画笔. 下面的不行,在panel里获取画笔,然后传到button1,根 ...

  8. 首次push本地代码到github上出现的问题及解决方案

    刚创建的github版本库,在push代码时出错: $ git push -u origin masterTo git@github.com:******/Demo.git ! [rejected] ...

  9. hlsl 和cg 涉及 mul 左乘 右乘

    error: 1. mul' implicit truncation of vector type 2. matrixXXX: array dimensions of(unknown scope en ...

  10. ios开发之网络基础

    1.网络访问的步骤 1> 建立NSURL 2> 建立NSURLRequest 3> 建立NSURLConnection 4> 开始连接 - (void)viewDidLoad ...