TIL16 - JS - Checking Data Type

Peter D Lee·2020년 8월 26일
0

JavaScript

목록 보기
5/19

The typeof Operator

When 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

0개의 댓글