1> typeof "foo"
2"string"
3> typeof true
4"boolean"
5> typeof 42
6"number"
7
8if(typeof bar === 'number') {
9 //whatever
10}
1// You can use the built-in method 'typeof' in order to check the variable datatype
2
3//examples:
4
5typeof "hello" // "string"
6
7//or
8var a = 1;
9typeof(a);
10//the output will be > 'number'