[ Web Proxy ]
URL:
Viewing: https://developer.mozilla.org/ja/docs/Web/JavaScript/Reference/Errors/Strict_non_simple_params [Back]  [Original]

SyntaxError: "use strict" not allowed in function with non-simple parameters - JavaScript | MDN

MDN Web Docs

View in English Always switch to English

SyntaxError: "use strict" not allowed in function with non-simple parameters

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

SyntaxError

"use strict" :

ECMAScript "use strict"

Function

sum a=1 b=2 :

js
function sum(a=1, b=2) {
  // SyntaxError: "use strict" not allowed in function with default parameter
  "use strict";
  return a + b;
}

strict strict "use strict" :

js
"use strict";
function sum(a = 1, b = 2) {
  return a + b;
}

Function

function :

js
var sum = function sum([a, b]) {
  // SyntaxError: "use strict" not allowed in function with destructuring parameter
  "use strict";
  return a + b;
};

:

js
var sum = (function () {
  "use strict";
  return function sum([a, b]) {
    return a + b;
  };
})();

this :

js
var callback = (...args) => {
  // SyntaxError: "use strict" not allowed in function with rest parameter
  "use strict";
  return this.run(args);
};

:

js
var callback = (() => {
  "use strict";
  return (...args) => {
    return this.run(args);
  };
})();


Web Proxy Viewer  |  New URL  |  Original Page