'...' three dot 함수
'array[i] || []' 함수
function sumWithRest(... args) {
for(let i = 0 ; i < args.length; ++i) console.log(args[i]);
return args.reduce((acc, cur) => acc + cur);
}
sumWithRest(1, 2, 3, 4);
function destructuringParam(... [a, b, c]) {
console.log(a, b, c);
}
destructuringParam(1, 2, 3);
let ar = ['hello', 'nello'];
let ar2 = ['dello', 'bello']
console.log(ar);
console.log(...ar);
console.log([...ar, ...ar2]);
//[ 'hello', 'nello' ]
//hello nello
//[ 'hello', 'nello', 'dello', 'bello' ]
x에 값이 있으면 x에 할당하거나 빈 배열 []로 초기화합니다.
var x = x || [];