typeof
OperatorWhen writing code, it is important to keep track of the data types of the variable values used in the code.
You can use the typeof
operator to check what a variable's value's data type is.
ex)
let myName = 'Peter'; let birthYear = 1991; let t = true; console.log(typeof myName); // Prints: string console.log(typeof birthYear); // Prints: number console.log(typeof t); // Prints: boolean