Last active
December 6, 2017 09:57
-
-
Save ivomota/a4013c2937cb7027da38 to your computer and use it in GitHub Desktop.
Types in Javascript
How to detect the data type of anything
This file contains hidden or 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
| var type_of = function(x) { | |
| var type = Object.prototype.toString.apply(x); | |
| return type.slice(type.indexOf(' ') + 1, -1); | |
| }; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment