Function.arguments

지원이 중단되었습니다: This feature is no longer recommended. Though some browsers might still support it, it may have already been removed from the relevant web standards, may be in the process of being dropped, or may only be kept for compatibility purposes. Avoid using it, and update existing code if possible; see the compatibility table at the bottom of this page to guide your decision. Be aware that this feature may cease to work at any time.

function.arguments 속성은 함수로 부터 넘겨 받은 arguments에 해당하는 배열과 같은 객체이다. 간단하게 arguments를 대신 사용하자. 이 속성은 strict mode에서 꼬리 호출 최적화 때문에 금지 된다.

설명

function.arguments 문법은 deprecated 되었다. 함수 내 에서 사용 가능한 객체arguments에 접근하는 추천되는 방법은 단순히 arguments변수로 참조하는 것이다.

반복문의 경우, 함수 f 가 여러번 호출 스택에 나타나면, f.arguments의 값은 함수의 가장 최근 호출 arguments를 나타낸다.

arguments의 값은 함수 실행 과정에서 특별한 호출이 없다면 일반적으로 null 이다 (즉, 함수가 호출은 되었으나 반환되지 않음).

예제

arguments object를 사용한 예시

js
function f(n) {
  g(n - 1);
}

function g(n) {
  console.log("before: " + g.arguments[0]);
  if (n > 0) {
    f(n);
  }
  console.log("after: " + g.arguments[0]);
}

f(2);

console.log("returned: " + g.arguments);

// Output

// before: 1
// before: 0
// after: 0
// after: 1
// returned: null

명세서

function.arguments는 표준이 아니다. ECMAScript 3에서 arguments를 참조하기 때문에 deprecated 되었다.

브라우저 호환성

BCD tables only load in the browser

같이 보기