Skip to content
Related Articles

Related Articles

JavaScript ReferenceError Deprecated caller or arguments usage

View Discussion
Improve Article
Save Article
  • Last Updated : 19 Aug, 2020
View Discussion
Improve Article
Save Article

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. 

HTML




<script>
'use strict';
function GFG_Fun() {
    return GFG_Fun.caller; // Error here
}
GFG_Fun();
</script>

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. 

HTML




<script>
'use strict';
function gfg(n) {
  return gfg.arguments[0]; // Error here
}
gfg(2);
</script>

Output:

TypeError: 'arguments', 'callee' and 'caller' are 
restricted function properties and cannot be accessed
in this context
My Personal Notes arrow_drop_up
Recommended Articles
Page :

Start Your Coding Journey Now!