arguments.length

Baseline Widely available

This feature is well established and works across many devices and browser versions. It’s been available across browsers since July 2015.

arguments.length プロパティは、関数に渡された引数の数が入ります。

解説

arguments.length プロパティは、実際に関数に渡された引数の数を提供します。これは、定義された仮引数の数以上にも以下にもなることがあります(Function.length を参照してください)。

arguments.length の使用

この例では、2 つ以上の数を加算する関数を定義しています。

js
function adder(base /*, n2, ... */) {
  base = Number(base);
  for (var i = 1; i < arguments.length; i++) {
    base += Number(arguments[i]);
  }
  return base;
}

メモ: Function.length と arguments.length の違いに注意してください。

仕様書

Specification
ECMAScript® 2025 Language Specification
# sec-arguments-exotic-objects

ブラウザーの互換性

Report problems with this compatibility data on GitHub
desktopmobileserver
Chrome
Edge
Firefox
Opera
Safari
Chrome Android
Firefox for Android
Opera Android
Safari on iOS
Samsung Internet
WebView Android
WebView on iOS
Deno
Node.js
length

Legend

Tip: you can click/tap on a cell for more information.

Full support
Full support

関連情報