What is the use of type of operator?
typeof
operator tells you the type of the value stored in a variable.
Example:
typeof 'Vidhushi' === 'string' // true
typeof 123 === 'number' // true
typeof {} === 'object' // true
Also, if a variable is not defined, typeof
operator doesn’t throw an error and instead returns undefined
type.