jQuery type() Method

Last Updated:

jQuery type() Method

The jQuery type() method determines the internal JavaScript [[Class]] of an object.

Example

HTML Editor
<!DOCTYPE html> <html lang="en-US"> <head> <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js"></script> </head> <body> <h1>jQuery type() Method</h1> <button>Click me</button> <script> var nodata; var str = "Hello World!"; var num = 25; var obj = {}; var arr = []; var myNull = null; var bool = true; var d = new Date(); var err = new Error(); var sym = Symbol(); var reg = /test/; var myFunction = function(){ //dummy function; } $(document).ready(function(){ $("button").click(function(){ console.log("nodata = " +$.type(nodata)); console.log("str = " +$.type(str)); console.log("num = " +$.type(num)); console.log("obj = " +$.type(obj)); console.log("arr = " +$.type(arr)); console.log("myNull = " +$.type(myNull)); console.log("bool = " +$.type(bool)); console.log("d = " +$.type(d)); console.log("err = " +$.type(err)); console.log("sym = " +$.type(sym)); console.log("reg = " +$.type(reg)); console.log("myFunction = " +$.type(myFunction)); }); }); </script> </body> </html>

Syntax

$.type(obj);

Parameter Values

Value Type Explanation
obj Required Specifies an item (anything) to find its type.

Browser Support

Devicedesktopmobile
Browsergoogle chromesafarifirefoxinternet Exploreredgeoperagoogle chromesafarifirefoxedgeoperaandroid webviewsamsung internet
type()YesYesYesYesYesYesYesYesYesYesYesYesYes

Share this Page

Meet the Author