snippet

How to use typeof in Javascript ?

You have 8 data types returning with typeof expression :
number: floating-point and integers
bigint: integer numbers of arbitrary length
string: just string, not a number
boolean: true or false
null: return this if a content is empty or don't not exist
undefined: return this if the content is not assigned
object: return this for array, complex data structures or object js


// Use typeof in your javascript code
const myVar = 12;
typeof myVar // Return number
Related snippets