B019-变量输出
typeof Array.prototype;
typeof Function.prototype;
typeof Object.prototype;
输出:
"object";
"function";
"object";
typeof Function.prototype 为啥是 function? function 并不是基础类型。可以看做是从 object 中扣出去的一部分 typeof 返回 function 的情形有:函数,匿名函数,class 类
javascript
typeof function () {} === "function";
typeof Function === "function";
Function 是一个构造函数,所以 typeof Function 返回 function 构造函数的原型对象通常是一个对象,所以
typeof Array.prototype; // 'object'
typeof Object.prototype; // 'object'
只有 Function.prototype 是非常特别的
拓展
typeof Boolean();
typeof Number("a");
typeof new String(1);
typeof new Function();
boolean number object function