Notice
Recent Posts
Recent Comments
Link
«   2024/07   »
1 2 3 4 5 6
7 8 9 10 11 12 13
14 15 16 17 18 19 20
21 22 23 24 25 26 27
28 29 30 31
Tags
more
Archives
Today
Total
관리 메뉴

옥수수, 기록

typeof 연산자 본문

CodeStates

typeof 연산자

ok-soosoo 2022. 10. 21. 10:59
typeof 연산자를 사용하여 값의 타입을 확인하는 방법

typeof 는 값의 타입을 확인할 수 있는 연산자이다.

typeof 1; // 'number' 출력
typeof '1'; // 'string' 출력
typeof false ; // 'boolean' 출력

추가로 변수에 할당한 값의 타입도 쉽게 확인할 수 있다.

let num = 1;
console.log(typeof num); // number
let string = '1';
console.log(typeof string); // string
let boolean = false;
console.log(typeof boolean); // boolean

 

'CodeStates' 카테고리의 다른 글

기술 면접 관련  (0) 2022.11.16
git 에 대한 정리  (0) 2022.11.11
12일차) JS 원시 자료형 & 참조 자료형  (0) 2022.11.07
Comments