JavaScript constructor 属性

定义和用法

constructor 属性返回创建 Number 原型的函数。

对于 JavaScript 数字,constructor 属性返回:function Number() { [native code] }

语法

number.constructor

实例

<html>
<body>
<script type="text/javascript">

var test=new Boolean();

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>

</body>
</html>

输出:

This is a Boolean

TIY

TIY

constructor
在本例中,我们将展示如何使用 constructor 属性。
系统帮助 | 给我留言 | 收藏本站
Copyright © 2005-2008 www.cnn84.com All Rights Reserved Ver:2.0 桂公网安备45122402000102号
CNN84网是公益性便民网站,是为了给大家的日常生活查询及提供最快捷的出行指南