Skip to content

Instantly share code, notes, and snippets.

@stdclass
Forked from 140bytes/LICENSE.txt
Created May 17, 2011 18:26
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save stdclass/977050 to your computer and use it in GitHub Desktop.
Save stdclass/977050 to your computer and use it in GitHub Desktop.
Type Checking
var is={};
(function(t,c,i,e,o){c=function(o){return function(v){return o==v.constructor;}};t=t.split(",");i=0;while(e=t[i++])this[e]=c(eval(e))})
.call(is, "String,Array,Object,Function,Number");
console.log( is.String( "123" ) ); // true
console.log( is.String( 123 ) ); // false
console.log( is.Number( 123) ); // true
console.log( is.Object( {} ) ); // true
(function(t,c,i,e,o){c=function(o){return function(v){return o==v.constructor;}};t=t.split(",");i=0;while(e=t[i++])this[e]=c(eval(e))})
{
"name": "typechecking",
"keywords": [ "check", "type", "checktype" ]
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment