JavaScript ReferenceError Deprecated caller or arguments usage
This JavaScript exception deprecated caller or arguments usage occurs only in strict mode. It occurs if any of the Function.caller or Function.arguments properties are used, Which are depreciated.
Message:
TypeError: 'arguments', 'callee' and 'caller' are restricted function properties and cannot be accessed in this context (Edge) Warning: ReferenceError: deprecated caller usage (Firefox) Warning: ReferenceError: deprecated arguments usage (Firefox) TypeError: 'callee' and 'caller' cannot be accessed in strict mode. (Safari)
Error Type:
This is a strict-mode warning that a ReferenceError occurred. JavaScript execution won't be halted.
Cause of the Error: In the code, the Function.caller or Function.arguments properties are used, Which are depreciated.
Example 1: In this example, the caller property is used, So the error has occurred.
Javascript
'use strict' ; function GFG_Fun() { return GFG_Fun.caller; // Error here } GFG_Fun(); |
Output:
TypeError: 'arguments', 'callee' and 'caller' are restricted function properties and cannot be accessed in this context
Example 2: In this example, the arguments property is used, So the error has occurred.
Javascript
'use strict' ; function gfg(n) { return gfg.arguments[0]; // Error here } gfg(2); |
Output:
TypeError: 'arguments', 'callee' and 'caller' are restricted function properties and cannot be accessed in this context