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

in javascript •  5 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
Authors get paid when people like you upvote their post.
If you enjoyed what you read here, create your account today and start earning FREE STEEM!