jQuery type() Method

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

ValueTypeExplanation
objRequiredSpecifies an item (anything) to find its type.

Reminder

Hi Developers, we almost covered 99.5% of jQuery Tutorials with examples for quick and easy learning.

We are working to cover every Single Concept in jQuery.

Please do google search for:

Join Our Channel

Join our telegram channel to get an instant update on depreciation and new features on HTML, CSS, JavaScript, jQuery, Node.js, PHP and Python.

This channel is primarily useful for Full Stack Web Developer.

Meet the Author