티스토리 뷰

백엔드

JavaScript의 변화 (CMAScript 2015 ~)

초딩영웅 2018. 9. 2. 18:18
  • const
    변수정의, 상수를 역할

  • let
    변수정의, 일반 변수

  • var
    변수정의, 사용가능하지만 이후 부터는 권장하지 않음. const, let 으로 대체

  • 템플릿 문자열
    var result = `{a} 와 {b}`;

  • 객체리터널 (중괄호으로 표현, const obj = { };)
    1) a function() {} => a() {}
    2) {say: say, hello: hello} => {say, hello} // 같은 네임이면 하나로 가능
    3) obj[es + 6] = 'woo' => {[es + 6]: 'woo'} // 올드오브젝트를 간단히 표현

  • 화살표 함수 ( => )
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    // 함수선언식은 그대로
    function add1(x, y) {
      return x + y
    }
     
    // 함수표현식
    // before
    const add2 = function(x, y) {
      return x + y;
    }
    // after 1
    const add2 = (x, y) => {
      return x + y;
    }
    // after 2
    const add2 = (x, y) => x + y;
    cs


  • 비구조화 할당 (destructuring)
    1
    2
    3
    4
    5
    6
    7
    8
    // before
    const apple = f.apple;
    const candy = f.candy;
     
    // after
    const { apple, candy } = f;
    // ex
    const { Router } = require('express');
    cs


'백엔드' 카테고리의 다른 글

Node.js API server 학습하기  (0) 2018.09.02
Authenticate a Node.js API with JSON Web Tokens  (0) 2015.10.29
[mysql] about with linux  (0) 2015.10.08
댓글