首页 > 代码库 > javascript Array对象的constructor属性
javascript Array对象的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==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属性
声明:以上内容来自用户投稿及互联网公开渠道收集整理发布,本网站不拥有所有权,未作人工编辑处理,也不承担相关法律责任,若内容有误或涉及侵权可进行投诉: 投诉/举报 工作人员会在5个工作日内联系你,一经查实,本站将立刻删除涉嫌侵权内容。