Skip to content

Instantly share code, notes, and snippets.

@ekazakov
Created August 24, 2013 19:02
Show Gist options
  • Save ekazakov/6329868 to your computer and use it in GitHub Desktop.
Save ekazakov/6329868 to your computer and use it in GitHub Desktop.
A Pen by Evgeniy Kazakov.
"use strict"
console.clear();
function classof(o) {
if ( o === null ) return "Null";
if ( o === undefined ) return "Undefined";
return Object.prototype.toString.call(o).slice(8, -1);
}
console.log( classof(null));
console.log( classof(undefined));
console.log( classof(1));
console.log( classof(""));
console.log( classof(false));
console.log( classof({}));
console.log( classof([]));
console.log( classof(/./));
console.log( classof(new Date()));
console.log( classof(window));
function f() {}
console.log( classof(new f()));
var o;
var b = function() {};
b.prototype.y = 1;
o = new b();
o.x = 2;
b.prototype.z = 2;
console.log( o)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment