| [ Web Proxy ] |
| Viewing: https://developer.mozilla.org/ru/docs/Web/JavaScript/Reference/Functions/arguments | [Back] [Original] |
Get to know MDN better
This page was translated from English by the community. Learn more and join the MDN Web Docs community.
This feature is well established and works across many devices and browser versions. Its been available across browsers since 2015 ..
* Some parts of this feature may have varying levels of support.
arguments , , .
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. , 3 , :
arguments[0];
arguments[1];
arguments[2];
:
arguments[1] = "new value";
arguments Array. , , length. , pop. , :
var args = Array.prototype.slice.call(arguments);
var args = [].slice.call(arguments);
// ES2015
const args = Array.from(arguments);
const args = [...arguments];
:
slice arguments JavaScript (, V8 ). , arguments. Array :
var args =
arguments.length === 1 ? [arguments[0]] : Array.apply(null, arguments);
arguments , . , . arguments.length, , arguments. , , Function.length.
typeof arguments typeof arguments 'object'.
console.log(typeof arguments); // 'object'
typeof .
// console.log(typeof arguments[0]);
arguments - , arguments Array.from() :
var args = Array.from(arguments);
var args = [...arguments];
arguments.callee, .
arguments.caller, , .
arguments.length.
arguments[@@iterator] Array Iterator, .
, . , - . :
function myConcat(separator) {
var args = Array.prototype.slice.call(arguments, 1);
return args.join(separator);
}
. , :
// "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- . , : "u", () , "o" ():
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>"; //
return result;
}
, . :
var listHTML = list("u", "One", "Two", "Three");
/* listHTML:
"<ul><li>One</li><li>Two</li><li>Three</li></ul>"
*/
function foo(...args) {
return arguments;
}
foo(1, 2, 3); // { "0": 1, "1": 2, "2": 3 }
, arguments , , . , , , , 10, 100:
function bar(a = 1) {
arguments[0] = 100;
return a;
}
bar(10); // 10
function zoo(a) {
arguments[0] = 100;
return a;
}
zoo(10); // 100
, , , arguments, arguments, arguments. :
function func(a, b) {
arguments[0] = 90;
arguments[1] = 99;
console.log(a + " " + b);
}
func(1, 2); //90, 99
function func(a, b) {
a = 9;
b = 99;
console.log(arguments[0] + " " + arguments[1]);
}
func(3, 4); //9, 99
function func(a, b, c = 9) {
arguments[0] = 99;
arguments[1] = 98;
console.log(a + " " + b);
}
func(3, 4); //3, 4
| Specification |
|---|
| ECMAScript 2027 LanguageSpecification # sec-arguments-exotic-objects |
This page was last modified on 24 . 2025 . by MDN contributors.
Your blueprint for a better internet.
Portions of this content are 19982026 by individual mozilla.org contributors. Content available under a Creative Commons license.
| Web Proxy Viewer | New URL | Original Page |