Skip to content

Instantly share code, notes, and snippets.

@jikeytang
Created June 1, 2014 01:43
Show Gist options
  • Save jikeytang/1960cb16a3b252505bcd to your computer and use it in GitHub Desktop.
Save jikeytang/1960cb16a3b252505bcd to your computer and use it in GitHub Desktop.
[ Javascript ] - 20140601-题目1
javascript里typeof返回的结果有哪几种?
PS:
1. 回复时注意加上下面这句话,才会有语法高亮或格式缩进。
```javascript
// you code
```
2. 粘贴代码时请使用shift+tab,缩进前面的空白。
@zouzg
Copy link

zouzg commented Jun 1, 2014

有6种,分别是:

typeof {} == "object"
typeof 10 == "number"
typeof function() {} == "function"
typeof "This is String" == "string"
typeof Undefined == "undefined"
typeof true == "boolean"

typeof 返回的是一个字符串

@hjzheng
Copy link

hjzheng commented Jun 3, 2014

https://github.com/hjzheng/JavaScript-Test-Type-Table
基本上已经涵盖了所有的类型判断

@hjzheng
Copy link

hjzheng commented Jun 3, 2014

补充两个上面链接中没有的:

typeof NaN == "number"
typeof arguments == "object"

@lovecn
Copy link

lovecn commented Jun 9, 2014

 typeof null =='object';
typeof [] =='object'

@qiangspecial
Copy link

object, function, boolean, number, string, undefined

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment