0. async vs defer
head + defer
1. 'use strict';
문법 실수 확인 가능
2. Variable, rw(read/write)
let{} ES6
밖에서 정의하면 업데이트X
global name : 밖에서 정의 가능
var hoisting : move declaration from bottom to top, has no block scope
* var 은 쓰지 마세요
→ 설정 전에 출력 가능하기 때문
3. Constant, r(read only)
use const whenever possible
only use let if variable needs to change
favor immutable data type always for a few reason
- security
- thread safety
- reduce human mistakes
+ NOTE!
immutable data types : primitive types, frozen objects 데이터 자체 변경 불가
mutable data types : all objects by default are mutable in JS
4. Variable types
primitive, single item : number, string, boolean, null, undefined, symbol
object, box container
NaN : 숫자가 아님
bigint
js 숫자 범위 : over (-2**53) ~ 2*53
5. String
template literals : `hi ${}!` 중간에 + '' 할 일이 없음
6. Boolean
false : 0, null, undefined, NaN, ''
true : any other value
7. null vs undefined
null : nothing이란 값
undefined : 아무런 값이 할당되지 않음
8. Symbol
create unique identifiers for objects
const symbol1 = Symbol('id');
const symbol2 = Symbol('id');
console.log(symbol1 === symbol2);
→ false
Symbol.for('id') 를 사용하면 true
9. Dynamic typing : dynamically typed language
let text = 'hello';
console.log(text.charAt(0)) : // h
[h, e, l, l, o]
10. Object
real - life object, data structure
object는 다른 object로 변경이 불가능
object 안에 있는 변수들은 수정 가능
const acorn = { name : 'accc', age : '10' };
'Programming > JavaScript' 카테고리의 다른 글
JS 문법 정리 (6) (0) | 2023.08.24 |
---|---|
JS 문법 정리 (5) (0) | 2023.08.22 |
JS 문법 정리 (4) (0) | 2023.08.18 |
JS 문법 정리 (3) (1) | 2023.08.15 |
JS 문법 정리 (2) (0) | 2023.08.15 |