Limited support 一部のブラウザのみ対応。使用時はサポート状況を確認すること。

概要

Function.prototype.caller と Function.prototype.arguments は非推奨のレガシープロパティです。strict モードでは使用できません。

対応ブラウザ

機能 デスクトップ モバイル
Chrome
Edge
Firefox
Safari
Chrome Android
Safari iOS
1
12
1
1
18
1
ビルトインオブジェクト
Function.caller
非推奨 非標準

caller は Function インスタンスのアクセサープロパティで、この関数を呼び出した関数を返します。厳格モード、アロー関数、非同期関数、ジェネレーター関数では、 caller プロパティにアクセスすると TypeError が発生します。

1
12
1
3
18
1
1+対応 (バージョン) 未対応 注釈あり サブ機能の解説は MDN Web Docs (CC BY-SA 2.5)

基本構文

JAVASCRIPT
// Function caller and arguments example
// See MDN Web Docs for details

ライブデモ

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 の活用

    Function.caller と Function.arguments(非推奨)。呼び出し元の関数や引数にアクセスするレガシー機能。

注意点

  • 一部のブラウザでのみ対応。使用前にブラウザサポートを確認すること。

アクセシビリティ

  • JavaScript による動的更新時は、aria-live リージョンで変更をスクリーンリーダーに通知する。

Powered by web-features