🔭
Ellery's study archive
Resume(수정중)GithubTistory
  • framework, library
    • Spring core
      • 스프링 트라이앵글 - POJO, IOC/DI, AOP, PSA
      • Servlet
    • Spring MVC
      • DispatcherServlet
      • Validation
    • Spring Boot
    • Spring Security
    • Spring Batch
    • Spring Webflux
    • JPA
    • JUnit, Spring Test
    • etc
      • Slf4j MDC(Mapped Diagnostic Context)
  • ETC, 개발 팁들
    • 개발 팁들
      • 스프링 프로젝트 init 시에 해야될 것들
      • vim 한글 깨질 때 인코딩 방식 지정
      • EC2 ssh connection 쉽게 하기
      • 리눅스 커맨드, netstats
      • Fork한 레포지토리 origin 업데이트
      • git merge, rebase
      • Intellij 자주 쓰는 기능 단축키
      • JSON handling
      • aws user-data.sh
    • Lombok annotation, 권장 방식
    • DB 모델링 시에 인조 식별자 정의하는 케이스
    • Redis pub/sub vs Apache kafka
  • Language
    • Java
      • 자바 버젼별 feature
      • JVM architecture
      • Garbage collection
      • Java String pool
      • java 8 Concurrent
      • Optional
      • Stream
      • Comparator, Comparator
      • Error, Exception
      • Java의 Call by value(pass by value)
      • Java 변수 간 값 Swap 방식 5가지
    • Javascript
      • 자주 쓰는 ES6 문법 정리
      • ES6 module
      • ES6 proxy
      • scope, var closure 이슈, let, const
    • Python
      • @lru_cache
  • CS
    • OS
      • Process, Thread
      • CPU scheduling
      • sync vs async, blocking vs nonblocking
      • Memory segmentation
      • virtual memory
      • 페이지 교체 알고리즘
    • Network
      • UDP
      • TCP
      • DNS
      • HTTP
      • web server, WAS
      • Proxy, Load balancer
      • web socket, WebRTC
      • gRPC
      • web secure
    • DB
      • MySQL
      • index
      • 정규화
      • DB 트랜잭션, 동시성 제어 문제
      • 클러스터링
      • 레플리케이션
      • 샤딩
    • Data Structure, Algorithm
      • AVL tree, Red black tree
      • B-tree, B*tree, B+tree
      • Hash
    • Design pattern
      • SOLID
      • 생성 패턴
        • 싱글톤 패턴
        • 팩토리 메서드 패턴
        • 빌더 패턴
        • Null 객체 패턴
      • 구조 패턴
        • 퍼사드 패턴
        • 프록시 패턴
        • 어댑터 패턴
        • 데코레이터 패턴
      • 행위 패턴
        • 전략 패턴
        • 템플릿 메서드 패턴
        • 상태 패턴
        • 옵저버 패턴
  • 소프트웨어 아키텍쳐
    • Layered Architecture
    • 클린 아키텍쳐
    • DDD
    • etc
      • DTO vs VO
  • 개발 서적들
    • 소트웍스 앤솔로지에서 소개되는 객체지향 생활 체조 원칙 간략 정리
    • 엘레강트 오브젝트 - 새로운 관점에서 바라본 객체지향
    • 만들면서 배우는 클린 아키텍쳐
  • 테크 블로그
Powered by GitBook
On this page
Edit on GitHub
  1. Language
  2. Javascript

자주 쓰는 ES6 문법 정리

  1. 기본적인 ES6 Desstructing assingnment 구조 분해 할당

[a, b] = [10, 20] // [10, 20]
[a, b] = [b, a]; // 변수 swap. [20, 10]

[a,b, ...rest] = [10, 20, 30, 40, 50]
console.log(rest) // [30, 40, 50]

const person = {
    name: 'Ellery Moon',
    familyName: 'Moon',
    givenName: 'Ellery'
    company: 'goodgood company',
    address: 'Seoul',
}

const { familyName, givenName } = person; // 객체에서 필요한 Key-value 엔티티만 꺼내 씀

// 객체 생성시 키 생략하기
const name = 'Ellery moon';
const company = 'goodgood company';
const person = { // 객체를 생성할 때 프로퍼티 키를 변수 이름으로 생략할 수 있음
  name,
  company
}
  1. 배열 loop를 함수형으로 작성

let sum = 0;
for(int i = 5; i < 10; ++i) {
	sum += i;
}

const sum = Array.from(new Array(5), (_, k) => k + 5).reduce((acc, cur) => acc + cur, 0);
  1. 중복 제거 Set, spread syntax (...)

const names = ['Lee', 'Kim', 'Park', 'Lee', 'Kim'];
const uniqueNamesWithArrayFrom = Array.from(new Set(names);
const uniqNamesWithSpread = [...new Set(names)];
  1. Spread syntax(...)를 이용한 객체 병합

const person = {
	name: 'Ellery Moon',
	familyName: 'Moon',
	givenName: 'Ellery'
}

const home = {
    name: 'pangyo',
    address: 'Seoul'
};

const MCM = { ...person, ...home };
/ {
//   address: 'Seoul'
//   familyName: 'Moon'
//   givenName: “Ellery”
//   name: 'pangyo' // **중첩되는 키는 마지막에 대입된 값으로 정해진다.**
// }
  1. &&, || 활용

const name = participantName || 'Guest'; // ||: default value 넣어주고 싶을 때 사용
// participantName이 0, undefined, 빈 문자열, null일 경우 'Guest'로 할당

flag && func(); /// && flag가 true일 경우에만 실행

const getCompany = (address) => { // 객체 병합에도 응용할 수 있음
  return {
    name: 'pangyo',
    ...address && { address: 'Seoul' }
  }};
console.log(getCompany(false)); // { name: 'pangyo' }
console.log(getCompany(true)); // { name: 'pangyo', address: 'Seoul'}
  1. 비구조화 할당 사용하기

const makeContract = ({ name1, name2, contractName }) => { // 함수에 객체를 넘길 경우 필요한 것만 꺼내 씀
  return {
    name1,
		name2,
    contractName
  }
};
const Contract = makeContract({ name1: 'Ellery', name2: 'goodgood company', contractName: 'stock-option' });
  1. 동적 속성

const nameKey = 'name';
const emailKey = 'email';
const person = {
  [nameKey]: 'Ellery',
  [emailKey]: 'Ellerymoon@gmail.com'
};
  1. !! 연산자: 0, null, '', undefined, NaN 값을 검사할 수 있음

function check(variable) {
  if (!!variable) { // 0, null, '', undefined, NaN이 들어오면 여길 통과할 수 없음
    console.log(variable);
  } else {
    console.error('잘못된 값');
  }
}
PreviousJavascriptNextES6 module

Last updated 2 years ago

Array.from() - JavaScript | MDN
구조 분해 할당 - JavaScript | MDN
Spread syntax (...) - JavaScript | MDN
Logo
Logo
Logo