let counter = 120; // counter is a number
console.log(typeof(counter)); // "number"
counter = false; // counter is now a boolean
console.log(typeof(counter)); // "boolean"
counter = "Hi"; // counter is now a string
console.log(typeof(counter)); // "string"Code language: JavaScript (javascript)
typeof("string"); //string
typeof(123); //number
// You can use the built-in method 'typeof' in order to check the variable datatype
//examples:
typeof "hello" // "string"
//or
var a = 1;
typeof(a);
//the output will be > 'number'
let store = [1,2,3]; console.log(typeof store);
typeof("iAmAString");//This should return 'string'
//NO camelCase, as it is a JS Keyword
typeof(variable)
> typeof "foo"
"string"
> typeof true
"boolean"
> typeof 42
"number"
var x = "Hello World";
typeof x; // "string"
if(typeof variable == 'object'){
//
}