데이터타입

Junny_·2022년 6월 24일
0

typeof 연산자

typeof는 타입을 모를때 사용하며 변수의 데이터 타입을 반환하는 연산자중 하나입니다.

typeof 연산자 사용법

typeof;

표현식반환값
typeof 1number
typeof "test"string
typeof (ture) or typeof (flase)boolean
typeof undefinedundefined
typeof fuction() {}function
typeof {}object

예제를 통해 보다 정확히 확인 가능 합니다.

console.log(typeof 1) // number
console.log(typeof "test") // string
console.log(typeof true) // boolean
console.log(typeof undefined) // undefined
console.log(typeof {}) // object
console.log(fuction() {}) // function

설명

number 숫자를 반환합니다
string 문자를 반환합니다
boolean 참과 거짓을 반환합니다
undefined 자료형이 정해지지 않은상태를 반환합니다
object 변수인 객채를 반환합니다
function 함수를 반환합니다

profile
Front-end

0개의 댓글