Categories
JavaScript Answers

How to find variable type in JavaScript?

Spread the love

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.

By John Au-Yeung

Web developer specializing in React, Vue, and front end development.

Leave a Reply

Your email address will not be published. Required fields are marked *