为什么 typeof 函数返回“函数"? [英] Why does typeof function return "function"?

查看:76
本文介绍了为什么 typeof 函数返回“函数"?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如果数组和函数都是对象子类型,那么为什么typeof function返回"function"typeof array返回"对象"?

If both array and function are object subtypes, then why does typeof function return "function" and typeof array return "object"?

推荐答案

因为 规范定义了typeof与对象交互时的不同行为实现[[Call]](即函数).

Because the specification defines different behaviour for typeof when it interacts with objects implementing [[Call]] (i.e. functions).

这篇关于为什么 typeof 函数返回“函数"?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆