Primitive values
- 원시값,
object
를 제외한 불변값.
- 기본형 타입으로
숫자
, 문자열
, 불리언
, null
, undefined
, symbol
이 있다.
null
을 제외하고 typeof
연산자로 테스트가 가능하다. === null
로 확인 가능하다.
const num = 20;
const num2 = 22.2;
console.log(`value: ${num}, type: ${typeof num}`);
console.log(`value: ${num2}, type: ${typeof num2}`);
const infinity = 1 / 0;
const negativeInfinity = -1 / 0;
const nAn = 'not a number' / 2;
console.log(infinity)
console.log(negativeInfinity)
console.log(nAn)
const char = 'c';
const min = 'min';
const seungit = 'hello ' + min;
console.log(`value: ${seungit}, type: ${typeof seungit}`)
const helloBob = `hi ${min}!`;
console.log(`value: ${helloBob}, type: ${typeof helloBob}`)
const canRead = true;
const test = 3 < 1;
console.log(`value: ${canRead}, type: ${typeof canRead}`)
console.log(`value: ${test}, type: ${typeof test}`)
let nothing = null;
console.log(`value: ${nothing}, type: ${typeof nothing}`)
let x;
console.log(`value: ${undifined}, type: ${typeof undifined}`)
const symbol1 = Symbol('id');
const symbol2 = Symbol('id');
console.log(symbol1 === symbol2);
const gSymbol1 = Symbol.for('id');
const gSymbol2 = Symbol.for('id');
console.log(symbol1 === symbol2);
console.log(`value: ${symbol1.description}, type: ${typeof symbol1}`)
const introduce = {name : "seungit", age : 20};
introduce.age = 22;
console.log(introduce.age);