-
Unit2 - Chapter2. 타입 (typeof 사용하기)블로깅 과제 2022. 10. 21. 10:31
변수의 타입에는 여러가지 타입이 존재한다. 값에 숫자가 할당된 number, 문자가 할당된 string, 참과 거짓이 할당된 boolean 등이 있다.
console.log(30) // number console.log('삼십') // string console.log(30 < 31) // boolean각 변수의 타입을 모를 경우 typeof 메소드를 사용해주면 된다. 사용법은 값 앞에 typeof를 사용해주면 된다.
console.log(typeof 30) // number가 출력된다. console.log(typeof '삼십') // string이 출력된다. console.log(typeof (30 < 31)) // boolean이 출력된다.이제 typeof 메소드를 이용하여 어떠한 변수든 타입을 알 수 있게 되었다!
'블로깅 과제' 카테고리의 다른 글
프로토 타입(object prototype) (0) 2022.11.18 객체 지향 프로그래밍 (0) 2022.11.18 클래스(class)와 인스턴스 객체(instance object) (0) 2022.11.18 이제까지 배운것 복습! (JavaScript Koans) (1) 2022.11.09 원시자료형과 참조자료형 (0) 2022.11.07