arguments 객체를 사용하여 함수 내에서 모든 인수를 참조할 수 있으며, 호출할 때 제공한 인수 각각에 대한 항목을 갖고 있습니다. 항목의 인덱스는 0부터 시작합니다.
function func1(a, b, c) {
console.log(arguments[0]);
// expected output: 1
console.log(arguments[1]);
// expected output: 2
console.log(arguments[2]);
// expected output: 3
}
func1(1, 2, 3);
예를 들어, 함수가 세 개의 인수를 받은 경우 다음과 같이 접근할 수 있습니다.
arguments[0]
arguments[1]
arguments[2]
각 인수를 설정하거나 재할당할 수도 있습니다.
arguments[1] = 'new value';
arguments 객체는 Array가 아닙니다. Array와 비슷하지만, length 빼고는 pop()과 같은 어떤 Array 속성도 없습니다. 그러나 실제 Array로 변환할 수 있습니다:
var args = [...arguments];
선언된 것보다 많은 인수로 함수를 호출하는 경우 arguments 객체를 사용할 수 있습니다
Date
Date 생성자는 시간의 특정 지점을 나타내는 Date 객체를 생성합니다.
let now = new Date();
new Date();
new Date(value);
new Date(dateString);
new Date(year, monthIndex[, day[, hour[, minutes[, seconds[, milliseconds]]]]]);
매개변수를 제공하지 않으면, 현지 시간으로 생성 순간의 날짜와 시간을 나타내는 Date 객체를 생성합니다.
javascript invoke function without parentheses