在本例中,我们将展示如何使用 constructor 属性:
</>code
- <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>
输出:
</>code
- This is an Array
在本例中,我们将展示如何使用 constructor 属性:
</>code
- <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>
输出:
</>code
- function employee(name, job, born)
- {this.name = name; this.job = job; this.born = born;}
如对本文有疑问,请提交到交流论坛,广大热心网友会为你解答!! 点击进入论坛
Powered by 365建站网 RSS地图 HTML地图
copyright © 2013-2024 版权所有 鄂ICP备17013400号