Easy Tutorial
❮ Html Csshooks Jquery Css Classes ❯

jQuery.type() Method

jQuery Miscellaneous Methods

Example

Is the parameter a regular expression?

Is this a regular expression? <b></b>
<script>
$(function () { 
    $( "b" ).append( "" + jQuery.type( /test/ ) );
})
</script>

Definition and Usage

The $.type() function is used to determine the type of a JavaScript built-in object and returns the type name in lowercase.

If the object is undefined or null, it returns "undefined" or "null" respectively.

$.type( undefined ) === "undefined"

$.type() === "undefined"

$.type( window.notDefined ) === "undefined"

$.type( null ) === "null"

If the object has an internal property [[Class]] and it matches the [[Class]] of a browser's built-in object, we return the corresponding [[Class]] name.

$.type( true ) === "boolean"

$.type( 3 ) === "number"

$.type( "test" ) === "string"

$.type( function(){} ) === "function"

$.type( [] ) === "array"

$.type( new Date() ) === "date"

$.type( new Error() ) === "error" // Added support in jQuery 1.9

$.type( /test/ ) === "regexp"

Syntax

Parameter Description
obj Any type The object of any type whose type needs to be determined.

jQuery Miscellaneous Methods

❮ Html Csshooks Jquery Css Classes ❯