Function caller and arguments
arguments は Function インスタンスのアクセサープロパティで、この関数に渡された引数を返します。厳格モード、アロー関数、非同期関数、ジェネレーター関数では、 arguments プロパティにアクセスすると TypeError が発生します。
対応ブラウザ
| 機能 | デスクトップ | モバイル | ||||
|---|---|---|---|---|---|---|
| Chrome | Edge | Firefox | Safari | Chrome Android | Safari iOS | |
Function.arguments 非推奨 非標準 | 1 | 12 | 1 | 1 | 18 | 1 |
Function.caller 非推奨 非標準 caller は Function インスタンスのアクセサープロパティで、この関数を呼び出した関数を返します。厳格モード、アロー関数、非同期関数、ジェネレーター関数では、 caller プロパティにアクセスすると TypeError が発生します。 | 1 | 12 | 1 | 3 | 18 | 1 |
ライブデモ
Inspect caller relationships
Read which function invoked another function in a legacy pattern.
JavaScript
出力
「実行」ボタンを押してください
Inspect function arguments length
Read the old function arguments object directly from inside the function.
JavaScript
出力
「実行」ボタンを押してください
Compare legacy and rest parameters
Show the older arguments object next to a modern rest parameter version.
JavaScript
出力
「実行」ボタンを押してください
実務での使いどころ
-
Function caller and arguments の活用
arguments は Function インスタンスのアクセサープロパティで、この関数に渡された引数を返します。
注意点
- 一部のブラウザでのみ対応。使用前にブラウザサポートを確認すること。
アクセシビリティ
- JavaScript による動的更新時は、aria-live リージョンで変更をスクリーンリーダーに通知する。