Answers for "how to check data type of javascript variable"

0

how to check data type of javascript variable

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)
Posted by: Guest on September-29-2021

Code answers related to "how to check data type of javascript variable"

Code answers related to "Javascript"

Browse Popular Code Answers by Language