Created
May 28, 2014 02:42
-
-
Save leohxj/7bea17e408c4178ed82d to your computer and use it in GitHub Desktop.
typeof运算符和Object.prototype.toString
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
typeof {foo: 'bar'}; | |
// "object" | |
typeof ['foo', 'bar']; | |
// "object" | |
typeof "foobar"; | |
// "string" | |
typeof /foo|bar/; | |
// "object" | |
Object.prototype.toString.call({foo: 'bar'}); | |
// "[object Object]" | |
Object.prototype.toString.call(['foo', 'bar']); | |
// "[object Array]" | |
Object.prototype.toString.call("foobar"); | |
// "[object String]" | |
Object.prototype.toString.call(/foo|bar/); | |
// "[object RegExp]" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment