In JavaScript, knowledge varieties outline the kind of worth a variable can maintain. To examine the kind of a variable, the typeof operator is used. The typeof operator returns a string indicating the kind of the operand. For instance, typeof 42 returns “quantity”, typeof “hi there” returns “string”, and typeof true returns “boolean”.
Checking the kind of a variable might be helpful for a wide range of causes. For instance, it may be used to make sure that a variable accommodates the anticipated kind of information, or to carry out completely different operations primarily based on the kind of knowledge.