[ Web Proxy ]
URL:
Viewing: https://developer.mozilla.org/ko/docs/Web/JavaScript/Reference/Functions/arguments [Back]  [Original]

arguments - JavaScript | MDN

This page was translated from English by the community. Learn more and join the MDN Web Docs community.

View in English Always switch to English

arguments

Baseline Widely available *

This feature is well established and works across many devices and browser versions. Its been available across browsers since 2015 7.

* Some parts of this feature may have varying levels of support.

arguments Array .

: ES6 .

: "Array " arguments length 0 , Array forEach, map .

In this article

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

arguments . arguments , . 0 .

, .

js
arguments[0];
arguments[1];
arguments[2];

.

js
arguments[1] = "new value";

arguments Array . Array , length pop() Array . Array :

js
var args = Array.prototype.slice.call(arguments);
var args = [].slice.call(arguments);

arguments Array ES2015 Array.from() .

js
var args = Array.from(arguments);
var args = [...arguments];

arguments . . arguments.length , arguments . signature , Function.length .

arguments.callee

.

arguments.caller

.

arguments.length

.

arguments[@@iterator]

arguments Array Iterator .

. . :

js
function myConcat(separator) {
  var args = Array.prototype.slice.call(arguments, 1);
  return args.join(separator);
}

.

js
// "red, orange, blue" 
myConcat(", ", "red", "orange", "blue");

// "elephant; giraffe; lion; cheetah" 
myConcat("; ", "elephant", "giraffe", "lion", "cheetah");

// "sage. basil. oregano. pepper. parsley" 
myConcat(". ", "sage", "basil", "oregano", "pepper", "parsley");

HTML

HTML . (bulluet( ) ) "u" ( ) "o" . :

js
function list(type) {
  var result = "<" + type + "l><li>";
  var args = Array.prototype.slice.call(arguments, 1);
  result += args.join("</li><li>");
  result += "</li></" + type + "l>"; // end list

  return result;
}

, . :

js
var listHTML = list("u", "One", "Two", "Three");

/* listHTML:

"<ul><li>One</li><li>Two</li><li>Three</li></ul>"

*/

,

arguments , .

js
function foo(...args) {
  return arguments;
}
foo(1, 2, 3); // { "0": 1, "1": 2, "2": 3 }

, mapped arguments , . , , 100 10 :

js
function bar(a = 1) {
  arguments[0] = 100;
  return a;
}
bar(10); // 10

, , , 100 :

js
function zoo(a) {
  arguments[0] = 100;
  return a;
}
zoo(10); // 100

Specification
ECMAScript 2027 LanguageSpecification
# sec-arguments-exotic-objects


Web Proxy Viewer  |  New URL  |  Original Page