function is(type, obj) {
var clas = Object.prototype.toString.call(obj).slice(8, -1);
return obj !== undefined && obj !== null && clas === type;
}
is('String', 'test'); // true
is('String', new String('test')); // true
In the above example, Object.prototype.toString
gets called with the value of this being set to the object whose [[Class]]
value should be retrieved.