[JS] typeof 연산자

ssumniee·2021년 6월 3일
0

typeof 연산자

typeof 연산자는 피연산자의 자료형을 문자열로 반환한다.

예시

let age = 27;
console.log(typeof age); // expected output: "number"
let myname = 'leezy';
console.log(typeof myname); // expected output: "string"
let isAdult = true;
console.log(typeof isAdult); // expected output: "boolean"

사용법

typeof 연산자는 피연산자 앞에 위치하게 사용하며
자료형을 가져올 객체 또는 원시값을 나타내는 표현식을 매개변수로 한다.

typeof age
typeof(age)
profile
개발에 뛰어든 UX/UI 디자이너

0개의 댓글