const count = 17; *// integer 정수*
const size = 17.1; *// decimal number 소수점의 숫자*
console.log(`value: ${count}, type: ${typeof count}`);
console.log(`value: ${size}, type: ${typeof size}`);
// number - speicla numeric values: infinity, -infinity, NaN
// 계산할때 나누고자하는 값을 정확하게 확인하지 않고 연산을 하면 에러가 발생
// 현업에서 이런 문제로 에러가 발생*
const infinity = 1 / 0; *//숫자를 0으로 나누면 무한대의 숫자가 발생*
const negativeInfinity = -1 / 0; *// 네거티브*
const nAn = 'not a number' / 2; *//숫자가 아닌 문자를 나누면 NaN값이 출력*
console.log(infinity);
console.log(negativeInfinity);
console.log(nAn)
bigInt (fairly new, don't use it yet)
숫자 마지막에 n을 붙이면 큰 숫자로 확인하는 최신 버젼 추가
const bigInt = 123456789012345678901234567890n;
// over (-2*53) ~ 253)
console.log(value: ${bigInt}, type: ${typeof bigInt}
);
Number.MAX_SAFE_INTEGER;
string 스트링끼리 +기호로 연결가능
const char = 'c';
const brendan = 'brendan';
const greeting = 'hello ' + brendan;
console.log(`value: ${greeting}, type: ${typeof greeting}`);
//template literals (string) 변수값을 붙일 수 있다.
const helloBob = `hi ${brendan}!`;
console.log(`value: ${helloBob}, type: ${typeof helloBob}`);
//이렇게 간편하게 출력가능
console.log('value: ' + helloBob + ' type: ' + typeof helloBob);
boolean
⇒ false: 0, null, undefined, NaN, ''
⇒ true: any other value
const canRead = true;
const test = 3 < 1; //false
console.log(`value: ${canRead}, type: ${typeof canRead}`);
console.log(`value: ${test}, type: ${typeof test}`);
null
let nothing = null;
console.log(`value: ${nothing}, type: ${typeof nothing}`);
let x;
console.log(`value: ${x}, type; ${typeof x}`);
symbol, create unique identifiers for objects
⇒ 고유한 식별자를 만들때 둘은 같지 않다.
const symbol1 = Symbol('id');
const symbol2 = Symbol('id');
console.log(symbol1 === symbol2); //false
// 스트링이 똑같다면 for을 사용해서 같게 만들어달라고 요청가능
const gSymbol1 = Symbol.for('id');
const gSymbol2 = Symbol.for('id');
console.log(gSymbol1 === gSymbol2); //true
// 출력시 .description사용하여 스트링으로 변환해서 출력해야함
console.log(`value: ${symbol1.description}, type: ${typeof symbol1}`);
object, real-life object, data structure
⇒ neo는 편경불가
name과 , age는 변경이 가능한 변수이기때문에
const neo = {name: 'neo', age: 100};
neo.age = 20; //변경이 가능