javascript
javascript arguments 객체
fd27
2021. 4. 14. 09:12
function add(x, y) {
console.log('arguments length:', arguments.length)
console.log('arguments:', arguments);
return x + y;
}
console.log('add result', add(5, 6, 7))
/*
arguments length: 3
arguments: [Arguments] { '0': 5, '1': 6, '2': 7 }
add result 11
*/
자바스크립트의 함수 안에서 arguments 객체를 사용할 수 있다. arguments 객체는 함수 호출시 인수가 저장되는 객체이다.