Latest web development tutorials

jQuery.type () method

jQuery Misc Methods jQuery Misc Methods

Examples

This parameter is a regular expression

This is a regular expression? <B> </ b> <script> $ (function () {$ ( "B" ). Append ( "" + JQuery. Type (/ test /) );}) </ Script>

try it"

Definition and Usage

$ .type () Function is used to determine the type of JavaScript built-in objects and returns the lowercase type name.

If the object is undefined or null, then returns the corresponding "undefined" or "null"

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

$.type() === "undefined"

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

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

If the object has an internal property [[Class]] and a browser's built-in objects [[Class]] the same, 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" // jQuery 1.9 新增支持

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

grammar

$.type( obj )

参数 描述
obj 任意类型 需要确定类型的任意对象。


jQuery Misc Methods jQuery Misc Methods