How to know the Data Type of a variable's value

in #javascript5 years ago

#JS-BEGINNERS-SERIES #lesson-002

How to know the Data Type of a variable

Sometimes beginner developers forget about the javascript data types, and in some situations, a developer needs to check the data type of a certain variable's value without searching on the internet.
There is an easy way in the js language itself which is the typeof operator

let myVar = "I am ";
console.log(typeof myVar);
//  output : string

let myNum = 14;
console.log(typeof myNum);
// output : number

let myAge = myVar + myNum;
console.log(typeof myAge);
// output : string