Skip to content

Instantly share code, notes, and snippets.

@jdelight
Last active September 8, 2015 13:27
Show Gist options
  • Save jdelight/a441a4eb3ab6f438138a to your computer and use it in GitHub Desktop.
Save jdelight/a441a4eb3ab6f438138a to your computer and use it in GitHub Desktop.
// Determining object [[Class]] with toString.call([value])
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