Sometimes, we want to find variable type in JavaScript.
In this article, we’ll look at how to find variable type in JavaScript.
How to find variable type in JavaScript?
To find variable type in JavaScript, we can use the typeof
operator.
For instance, we write
typeof "foo"
to return 'string'
since 'foo'
is a string.
We can use this with other primitive values like numbers and booleans. It also works with functions.
Conclusion
To find variable type in JavaScript, we can use the typeof
operator.