21.javascript 中constructor属性


constructor 属性返回所有 JavaScript 变量的构造函数。

"Bill".constructor                    // 返回 function String()  {[native code]}
(3.14).constructor                  // 返回 function Number()  {[native code]}
false.constructor                    // 返回 function Boolean() {[native code]}
[1,2,3,4].constructor             // 返回 function Array()   {[native code]}
{name:'Bill',age:19}.constructor  // 返回 function Object()  {[native code]}
new Date().constructor            // 返回 function Date()    {[native code]}
function () {}.constructor        // 返回 function Function(){[native code]}