Answers for "how to tell variable type in javascript"

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 tell variable type in javascript"

Code answers related to "Javascript"

Browse Popular Code Answers by Language