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
let animalName = ‘Bongo’;
console.log( typeof animalName );
The console log should output string as the type of the variable “animalName”.
Typeof method
console.log( typeof( animalName ) );
Again, the console log should output string as the type of the variable “animalName”.
Happy Coding!
Clay Hess