자바스크립트/Vanilla Js
Vanilla JS - REST 문법 (배열)
RightHot
2018. 12. 12. 20:33
REST 문법 (배열)
순서대로 넣는게 아니라, 남은 요소를 다 넣고을땐 아래처럼 하면 된다.
rest로 여러개의 변수를 모아서 배열로 만든다.
const array = ['nodeJs', {}, 10, true];
const [node, obj, bool] = array;
bool; // [10, true]
const m = (x,y) => console.log(x,y);
m(5,6) // 5, 6
m(5,6,7,8,9) // 5, 6
const n = (x, y) => console.log(x,y);
n(5,6,7,8,9) // 5, [6,7,8,9]