问题
If both array and function are object subtypes, then why does typeof function return "function" and typeof array return "object"?
回答1:
Because the specification defines different behaviour for typeof when it interacts with objects implementing [[Call]] (i.e. functions).
回答2:
Very ugly, yet correct answer: because ECMAScript specification says so. Keep in mind that on the low level, every array is basically a mere object with "length" property.
If you want to check if given object is actually an array, use Array.isArray.
来源:https://stackoverflow.com/questions/42467581/why-does-typeof-function-return-function