Friday, September 5, 2025
HomeLanguagesJavascriptJavaScript SyntaxError – “use strict” not allowed in function with non-simple...

JavaScript SyntaxError – “use strict” not allowed in function with non-simple parameters

This JavaScript exception ‘use strict’ not allowed in function occurs if strict modes ‘use strict’ statement is used at the beginning of a function with default parameters, rest parameters, or destructuring parameters.

Message:

Edge: Cannot apply strict mode on functions 
      with non-simple parameter list
Firefox:
SyntaxError: "use strict" not allowed in function 
              with default parameter
SyntaxError: "use strict" not allowed in function 
              with rest parameter
SyntaxError: "use strict" not allowed in function
              with destructuring parameter
Chrome:
SyntaxError: Illegal 'use strict' directive in function 
             with non-simple parameter list

Error Type:

SyntaxError

Cause of Error: A strict modes “use strict” is written at the start of a function that has the Default, Rest, or Destructing Parameters.

Example 1: In this example, the default parameter is not used, So the error has not occurred.

HTML




<script
  function GFG(a, b) {
            'use strict';
            return a + b;
    
  document.write(GFG(2, 5)); 
</script>


Output:

7

Example 2: In this example, the default parameter is used, So the error has occurred.

HTML




<script
  function GFG(a=2, b=3) {
            'use strict';
            return a + b;
    
  document.write(GFG(2, 5)); 
</script>


Output(In console):

SyntaxError: Illegal 'use strict' directive in
function with non-simple parameter list
Whether you’re preparing for your first job interview or aiming to upskill in this ever-evolving tech landscape, neveropen Courses are your key to success. We provide top-quality content at affordable prices, all geared towards accelerating your growth in a time-bound manner. Join the millions we’ve already empowered, and we’re here to do the same for you. Don’t miss out – check it out now!
RELATED ARTICLES

Most Popular

Dominic
32264 POSTS0 COMMENTS
Milvus
81 POSTS0 COMMENTS
Nango Kala
6634 POSTS0 COMMENTS
Nicole Veronica
11801 POSTS0 COMMENTS
Nokonwaba Nkukhwana
11863 POSTS0 COMMENTS
Shaida Kate Naidoo
6750 POSTS0 COMMENTS
Ted Musemwa
7025 POSTS0 COMMENTS
Thapelo Manthata
6701 POSTS0 COMMENTS
Umr Jansen
6718 POSTS0 COMMENTS