- 동적 타이핑 : 런타임 시점에 변수에 할당되는 값에 따라 자동으로 데이터 타입이 결정
- untime : 코드를 작성할 떄가 아니라, 실제 코드가 실행될 때 -> 터미널에 코드가 실행될 때 그 때, 데이터 타입이 결정된다
- Java : String a = "abc"; → 데이터 타입을 정해서 변수 선언
- JavaScript : const a = "abc"; → 런타임에 데이터 타입이 결정됨
// 1.숫자 (Number)
let num1 = 10;
console.log(num1);
console.log(typeof num1);
let num4 = "Hello" / 2; // NaN
// NaN : Not a Number 숫자로 계산이 안되는 경우
// 2. 문자 : string (문자열 = 문자의 나열)
// ' ' = " "
let str = "Hello World";
// console.log(str);
// console.log(typeof str);
// 3. 불리언 (Boolean)
// true(참), fales(거짓)
let bool1 = true;
let bool2 = false;
// console.log(bool1);
// console.log(typeof bool1);
// console.log(bool2);
// console.log(typeof bool2);
// 4. undefined : 정의되지 않았다
let x;
// console.log(x);
// 5. null : 값이 존재하지 않음을 '명시적'으로 나타내는 방법
// null과 undefined는 다른 값이다
let y = null;
// console.log(y);
심벌도 있지만 이건 아직 알려주지 않으니 여기까지만 정리
'오늘 뭐했냐 > 개발에 대한 주저리' 카테고리의 다른 글
비교 연산자 (0) | 2023.05.22 |
---|---|
연산자 (0) | 2023.05.22 |
형 변환 (0) | 2023.05.22 |
데이터 타입(객체타입) (0) | 2023.05.22 |
변수 (0) | 2023.05.22 |