변수의 값, 변수에 담을 수 있는 데이터타입은 가장 작은 단위(primitive type)인 number, string, boolean, null. undefined, symbol 이 있다.
객체 타입과 비교하며 알아보기 → 객체 object type
const number = 17; // 정수 // 값 value: 17, type: number
const num = 17.1; // 소수점 // 값 value: 17.1 type: number
const infinity = 1 / 0; // 숫자를 0으로 나눔 => 무한대숫자값
const negativeInfinity = -1 / 0; // - 숫자로 나눔 (- nagative value)
const nAn = 'not a number' / 2; // 숫자가 아닌 string 값을 나눌때 nAn
console.log(infinity); // Infinity
console.log(negativeInfinity); // -Infinity
console.log(nAn); // NaN
const char = 'c'; // string type 할당
const greeting = 'hello' + char; //
// string 타입의 값에 다른 변수를 + 기호를 이용하여 이어 붙일 수 있으며
// = string type으로 모두 변경된다.
console.log(greeting) = "helloc"
'10' === 10 // fase 출력
35 === 35 // true 출력
let nothing = null;
let x;
let x = undefined;
// 주어지는 str에 상관없이 각각의 고유한 식별자
const symbol1 = Symbol('id');
const symbol2 = Symbol('id');
console.log(symbol1) === symbol2); // false
// 주어지는 str이 똑같을때, 동일한 심볼을 만들고 싶을때
const gsymbol1 = Symbol.for('id');
const gsymbol2 = Symbol.for('id');
console.log(gsymbol1) === gsymbol2); // true
// symbol은 string으로 변환해서 출력해야함./ .desription를 뒤에 붙여서
// 예를 들어 symboll.desription
둘다 선언된 변수의 값이며, null은 아무값도 명확하게 없다고 우리가 직접 할당해준 값, undefined는 그냥 아무값도 지정되어 있지않는 값을 나타내는 것이다.
즉, 우리가 할당을 했는지 할당을 하지 않았는 지에 따라 나뉜다.
드림코딩엘리
https://www.youtube.com/watch?v=OCCpGh4ujb8&list=PLv2d7VI9OotTVOL4QmPfvJWPJvkmv6h-2&index=3