Skip to content

Instantly share code, notes, and snippets.

@jaubourg
Created April 29, 2011 02:16
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jaubourg/947722 to your computer and use it in GitHub Desktop.
Save jaubourg/947722 to your computer and use it in GitHub Desktop.
// Create type-related methods:
// isArray, isBoolean, isDate, isFunction, isObject, isNumber, isRegExp, isString and type
jQuery.isFunction = jQuery.noop;
jQuery.each( "Array Boolean Date Function Object Number RegExp String ".split(" "), function( lName, name ) {
lName = class2type[ "[object " + name + "]" ] = name.toLowerCase();
jQuery[ name ? ( "is" + name ) : "type" ] = nativeTypeTests[ name ] || function( value ) {
value = value == null ?
String( value ) :
class2type[ toString.call( value ) ] || "object";
return name ? ( value === lName ) : value;
};
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment