[ECMAScript] ES6

빛트·2022년 7월 13일
0

ECMASCRIPT

목록 보기
2/8
post-thumbnail

Let and Const

let x;
const y = "y"; 

Template Literals

const serverUrl = "http://localhost:3000";
const fetchUrl = `${serverUrl}/user`;

const str = `
	multiline-1
	multiline-2
`

Arrow Functions

const foo = () => {
  return true;
}

Default Parameters

const printColor = (color = 'red') => {
	console.log(color);
}

Destructuring Assignment

const {name, age} = store.user;

Enhanced Object Literals

let name = "bit";
let age = 19;

const user = {
  name, 
  age,
  getName(){
    return this.name;
  }
}

Promise

let promise = new Promise((resolve, reject) => {
	// ...
});

promise.then(()=>{}).catch(()=>{});

Class

class User {
  constructor(name) {
    this._name = name;
  }

  sayHi() {
    console.log(`Hi! ${this._name}`);
  }
}

Module

export const SERVER_URL = "https://velog.io";
import {SERVER_URL} from "../common/const.js";

const url = `${SERVER_URL}/@kangbit`

Poiemaweb
개발자가 필히 알아야 할 ES6 10가지 기능

0개의 댓글