英 [k?n?str?kt?(r)]? ?美 [k?n'str?kt?]??
n.構(gòu)造器
## 複數(shù):constructors
JavaScript 建構(gòu)函式屬性 語法
constructor屬性是什麼意思?
constructor存在於每一個function的prototype屬性中,constructor屬性是傳回對建立此物件的陣列函數(shù)的參考。
作用:傳回對建立此物件的陣列函數(shù)的參考。
語法:object.constructor
#說明:constructor 屬性傳回對建立此物件的陣列函數(shù)的參考。
註解:無
JavaScript 建構(gòu)函式屬性 範例
<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>
執(zhí)行實例 ?
點擊 "執(zhí)行實例" 按鈕查看線上實例