자주 쓰는 문법들만 쓰다 보니 모르는 게 너무 많은 것 같아서 공부하고자 기록한다
계속해서 모르는 걸 찾을 때마다 추가적으로 기록할 예정
// rest parameters 배열
function testRestParams(a, b, ...args) {
console.log("a", a); // a 1
console.log("b", b); // b 2
console.log("and more", args); // and more [3,4,5,6]
}
testRestParams(1,2,3,4,5,6);
// arguments 유사배열
function testArguments(){
console.log(arguments); // [Arguments] { '0': 1, '1': 2, '2': 3 }
const arr = Array.from(arguments); // 배열로 만들어서 사용해야함
console.log('arr', arr); // arr [1,2,3]
}
testArguments(1,2,3)
https://developer.mozilla.org/ko/docs/Web/JavaScript/Reference/Functions/rest_parameters