[자바 스크립트] 자료형 검사, undefined 자료형

남한탐정김정은·2023년 1월 9일
0

자바스크립트

목록 보기
6/32
post-thumbnail

자료형 검사 typeof

자바스크립트는 하나에 변수에 여러 자료형을 넣을 수 있다.
자료형의 확인이 필요할시 typeof '연산자'를 사용한다.

> typeof(10)
'number'
> typeof("문자열")
'string'
> typeof(true)
'boolean'
> typeof(function (){})
'function'
> typeof({})
'object'

//아직 자료형이 정해지지 않은 경우
> let alpha //초기화하지 않은 변수
> typeof(alpha)
'undefined'

//선언을 하지 않은 경우
> typeof(beta)
'undefined'
profile
남한에 놀러온 김..

0개의 댓글