If you want to check if a variable is a string, then use the
typeof operator returns "string" if a variable is a string.
On the other hand, if a variable is not a string, then the
typeof operator returns a different value.
The syntax for using the
typeof operator with a string is
Let's understand the process with the help of an example:
Variable x is a string.