JavaScript typeof Operator

You are Here:

JavaScript typeof Operator

The typeof operator returns a string indicating the type of the unevaluated operand.

Example

HTML Online Editor
<!DOCTYPE html> <html> <body> <script> var num = 36; var str = "hello"; var bool = true; var arr = [1, 2, 3]; var obj = {bike: "honda", color: "red"}; var txt = ""; txt += "num : "+typeof num + "<br>"; txt += "str : "+typeof str + "<br>"; txt += "bool : "+typeof bool + "<br>"; txt += "arr : "+typeof arr + "<br>"; txt += "obj : "+typeof obj + "<br>"; document.write(txt); </script> </body> </html>

Syntax

typeof operand

Return Values

The following table summarizes the possible return values of typeof.

TypeResult
Undefined"undefined"
Null"object"
Boolean"boolean"
String"string"
Number"number"
BigInt"bigint"
Symbol"symbol"
Function object"function"
Any other object"object"

Reminder

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

We are working to cover every Single Concept in JavaScript.

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.

Share this Page

Meet the Author