나머지 매개변수와 전개 문법

트릴로니·2021년 12월 3일

자바스크립트

목록 보기
11/31

Spread

const newArray = {...oldArray, 1, 2}
..old object: old object에서 모든 프로퍼티를 꺼내서
newObjects에 삽입
const newObject = {...oldObject, newProp: 5}

Rest

function srotArgs(...args){
return args.sort()
}
sortArgs 엄청나게 많은 매개변수를 받을 수 있음
...arg를 배열로 받을 수 있음
배열 메소드 적용가능


매개변수에 배열함수 쓸 수 있음

0개의 댓글