JS 문법 정리

2023. 8. 14. 15:31·Programming/JavaScript

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
'Programming/JavaScript' 카테고리의 다른 글
  • JS 문법 정리 (5)
  • JS 문법 정리 (4)
  • JS 문법 정리 (3)
  • JS 문법 정리 (2)
gitit
gitit
짬내서 쓰는 프론트엔드와 기술 메모 공간
  • gitit
    깃잇-gitit
    gitit
  • 전체
    오늘
    어제
    • 분류 전체보기
      • Coding Test
        • Programmers
        • BackJoon
      • Development Tools
        • Firebase
        • Git
        • Monorepo
      • Programming
        • JavaScript
        • React
        • React-Native
      • etc.
        • GeekNews
        • Blockchain
      • Technical Interview
  • 블로그 메뉴

    • 홈
    • 태그
    • 방명록
  • 링크

  • 공지사항

  • 인기 글

  • 태그

    AWS
    독학
    React
    geeknews
    frontend
    파이썬
    javascript
    파이어베이스
    긱뉴스
    백준
    알고리즘
    modal
    기술 질문
    자바스크립트
    리액트
    개발
    node.js
    매일메일
    기본문법
    코딩
    프로그래머스
    코테
    코딩테스트
    styled-components
    BFS
    kakao
    Firebase
    FE
    프론트엔드
    js
  • 최근 댓글

  • 최근 글

  • hELLO· Designed By정상우.v4.10.1
gitit
JS 문법 정리
상단으로

티스토리툴바