Skip to content

Instantly share code, notes, and snippets.

@brianleroux
Created July 26, 2010 17:09
Show Gist options
  • Save brianleroux/490852 to your computer and use it in GitHub Desktop.
Save brianleroux/490852 to your computer and use it in GitHub Desktop.
// by way of http://dmitry.baranovskiy.com/post/typeof-and-friends
function is(o, type) {
type = String(type).toLowerCase();
return (type == "null" && o === null) ||
(type == typeof o) ||
(type == "object" && o === Object(o)) ||
(type == "array" && Array.isArray && Array.isArray(o)) ||
Object.prototype.toString.call(o).slice(8, -1).toLowerCase() == type;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment