typeof(Array,null)返回object,typeof(null,Array)返回function [英] typeof (Array, null) returns object and typeof(null, Array) returns function

查看:115
本文介绍了typeof(Array,null)返回object,typeof(null,Array)返回function的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

正如标题所说, typeof(Array,null)返回 object typeof(null,Array)返回函数

As the title says it all, typeof (Array, null) returns object and typeof(null, Array) returns function.

它返回的类型第二个参数。

It returns the type of the second parameter.

为什么?

推荐答案

因为

  • typeof is an operator, not a function, so typeof(expr) is typeof expr, with expr evaluated first
  • a,b returns b

所以

typeof(a,b)返回 typeof b

,在您的情况下


  • typeof(Array,null) typeof null object

  • typeof(null,Array) typeof Array ,和数组是一个函数。

  • typeof (Array, null) is typeof null which is "object"
  • typeof(null, Array) is typeof Array, and Array is a function.

这篇关于typeof(Array,null)返回object,typeof(null,Array)返回function的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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