Check Type of JS Object
function objIs(type, obj) {
var clas = Object.prototype.toString.call(obj).slice(8, -1);
return obj !== undefined && obj !== null && clas === type;
}
objIs('String', 'test'); // true
objIs('String', new String('test')); // true
No comments:
Post a Comment