Skip to content

Getting the type of a variable

Getting the type of a variable using typeof

The typeof operator returns a string indicating the type of the operand’s value.

console.log(typeof 12) // "number"
console.log(typeof 'open source') //"string"
console.log(typeof true) // "boolean"