Last active
September 8, 2015 13:27
-
-
Save jdelight/a441a4eb3ab6f438138a to your computer and use it in GitHub Desktop.
// Determining object [[Class]] with toString.call([value])
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
var o = {length: 12}; | |
var a = []; | |
var f = function(){}; | |
var b = true; | |
var r = /^abc/; | |
var n = 0; | |
var u = void 0; | |
var l = null; | |
console.log(toString.call(o)); // [object Object] | |
console.log(toString.call(a)); // [object Array] | |
console.log(toString.call(f)); // [object Function] | |
console.log(toString.call(b)); // [object Boolean] | |
console.log(toString.call(r)); // [object RegExp] | |
console.log(toString.call(n)); // [object Number] | |
console.log(toString.call(u)); // [object Undefined] | |
console.log(toString.call(l)); // [object Null] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment