Created
September 29, 2014 22:39
-
-
Save weslleyaraujo/d1e74800f85587b166f3 to your computer and use it in GitHub Desktop.
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
function TypeOf () { | |
return Object.prototype.toString.call(this) | |
.replace(/(\bobject\b\s)/g, '') | |
.replace(/\[/g, '') | |
.replace(/\]/g, '') | |
.toLowerCase(); | |
}; | |
console.log(TypeOf.call({})); // object | |
console.log(TypeOf.call([])) // array | |
console.log(TypeOf.call(TypeOf)) // function | |
console.log(TypeOf.call(1)) // number |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment