JavaScript concept with a cup of coffee and a laptop

Variable Types

Since a variable can hold numerous data types, it is important to ensure that the value of a variable is the expected data type. In JavaScript, this can be done with the typeof operator or method. They both pretty much do the same thing but have syntax differences.

Typeof operator

The console log should output string as the type of the variable “animalName”.

Typeof method

Again, the console log should output string as the type of the variable “animalName”.

Happy Coding!

Clay Hess

Share this post

Share on facebook
Share on google
Share on twitter
Share on linkedin
Share on pinterest
Share on print
Share on email
Skip to content