欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

JavaScript constructor 屬性

定義和用法

constructor 屬性返回對創(chuàng)建此對象的數(shù)組函數(shù)的引用。

語法

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 屬性。