JavaScript constructor 屬性
定義和用法
constructor 屬性返回對(duì)創(chuàng)建此對(duì)象的 Boolean 函數(shù)的引用。
語法
object.constructor
實(shí)例
在本例中,我們將展示如何使用 constructor 屬性:
<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>
輸出:
This is a Boolean
TIY
- constructor
- 在本例中,我們將展示如何使用 constructor 屬性。