Skip to content

Instantly share code, notes, and snippets.

@rexfordkelly
Created August 23, 2016 00:52
Show Gist options
  • Save rexfordkelly/2b5f61327c73735d1ca9f653eb6f8329 to your computer and use it in GitHub Desktop.
Save rexfordkelly/2b5f61327c73735d1ca9f653eb6f8329 to your computer and use it in GitHub Desktop.
var q = (function () {
return 'Array,Boolean,Date,Function,Null,Number,Object,RegExp,String,Undefined'.split(',').reduce( function( checker, type ){
checker['is' + type] = ( function (identity){
return function (context) {
return Object.prototype.toString.call(context).slice(8, -1) === identity;
};
})( type );
return checker;
}, {});
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment