英 [k?n?str?kt?(r)]? ?美 [k?n'str?kt?]??
n.構(gòu)造器
復(fù)數(shù): constructors
javascript constructor屬性 語法
constructor屬性是什么意思?
constructor存在于每一個(gè)function的prototype屬性中,constructor屬性是返回對(duì)創(chuàng)建此對(duì)象的數(shù)組函數(shù)的引用。
作用:返回對(duì)創(chuàng)建此對(duì)象的數(shù)組函數(shù)的引用。
語法:object.constructor
說明:constructor 屬性返回對(duì)創(chuàng)建此對(duì)象的數(shù)組函數(shù)的引用。
注釋:無
javascript constructor屬性 示例
<html> <body> <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> </body> </html>
運(yùn)行實(shí)例 ?
點(diǎn)擊 "運(yùn)行實(shí)例" 按鈕查看在線實(shí)例