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

- JavaScript | MDN

MDN Web Docs

View in English Always switch to English

JavaScript (Strict mode) JavaScript sloppy

JavaScript

  1. JavaScript
  2. JavaScript
  3. ECMAScript

{} eval Function setTimeout()

"use strict"; ( 'use strict';)

js
// 
"use strict";
const v = "";

"use strict"; ( 'use strict';)

js
function myStrictFunction() {
  // 
  "use strict";
  function nested() {
    return "";
  }
  return ` ${nested()}`;
}
function myNotStrictFunction() {
  return "";
}

"use strict" "use strict"

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

JavaScript

js
function myStrictFunction() {
  // 
}
export default myStrictFunction;

js
class C1 {
  // 
  test() {
    delete Object.prototype;
  }
}
new C1().test(); // TypeError test() 

const C2 = class {
  // 
};

// 
delete Object.prototype; // 

  • ()
  • eval arguments
  • JavaScript
  • ECMAScript

JavaScript

js
"use strict";
let mistypeVariable;

//  mistypeVarible 
//  "mistypeVariable" 
// "a"  ReferenceError 
mistypeVarible = 17;

3

NaN NaN NaN

js
"use strict";

// 
undefined = 5; // TypeError
Infinity = 5; // TypeError

// 
const obj1 = {};
Object.defineProperty(obj1, "x", { value: 42, writable: false });
obj1.x = 9; // TypeError

// 
const obj2 = {
  get x() {
    return 17;
  },
};
obj2.x = 5; // TypeError

// 
const fixed = {};
Object.preventExtensions(fixed);
fixed.newProp = "ohai"; // TypeError

deleteProperty false

js
"use strict";
delete Object.prototype; // TypeError
delete [].length; // TypeError

delete name

js
"use strict";

var x;
delete x; // syntax error

globalThis

js
"use strict";

delete globalThis.x;

arguments

js
function sum(a, a, c) {
  // 
  "use strict";
  return a + a + c; // 
}

8

0 8 8 0644 0 8 8 (0644 === 420) 8

js
"use strict";
const sum =
  015 + // 
  197 +
  142;

8 0o

js
const sumWithOctal = 0o10 + 8;
console.log(sumWithOctal); // 16

8 ASCII "%" "\45" 8 \ 0 \0 \9 \07

TypeError

js
"use strict";

false.true = ""; // TypeError
(14).sailing = "home"; // TypeError
"with".you = "far away"; // TypeError

SyntaxError ECMAScript 2015

js
"use strict";
const o = { p: 1, p: 2 }; // ECMAScript 2015 

:

X JavaScript JavaScript

with

with with with with

js
"use strict";
const x = 17;
with (obj) {
  // 
  //  const x 
  // obj.x 
  // 
  // 
  x;
}

with

eval

eval eval("var x;") x eval eval eval eval

js
var x = 17;
var evalX = eval("'use strict'; var x = 42; x;");
console.assert(x === 17);
console.assert(evalX === 42);

eval() eval() eval eval

JavaScript

eval arguments

arguments eval eval arguments eval arguments

eval arguments

eval arguments

js
"use strict";
eval = 17;
arguments++;
++eval;
const obj = { set p(arguments) {} };
let eval;
try {
} catch (arguments) {}
function x(eval) {}
function arguments() {}
const y = function eval() {};
const f = new Function("arguments", "'use strict'; return 17;");

arguments

arguments arg arg arguments[0] arguments[0] arguments arguments[i]

js
function f(a) {
  "use strict";
  a = 42;
  return [a, arguments[0]];
}
const pair = f(17);
console.assert(pair[0] === 42);
console.assert(pair[1] === 17);

JavaScript

JavaScript JavaScript JavaScript JavaScript JavaScript

this

this this this this this undefined null this callapplybind JavaScript this globalThis undefined

js
"use strict";
function fun() {
  return this;
}
console.assert(fun() === undefined);
console.assert(fun.call(2) === 2);
console.assert(fun.apply(null) === null);
console.assert(fun.call(undefined) === undefined);
console.assert(fun.bind(true)() === true);

JavaScript fun fun.caller fun fun.arguments fun arguments JavaScript fun fun.caller fun.arguments

js
function restricted() {
  "use strict";
  restricted.caller; // TypeError 
  restricted.arguments; // TypeError 
}
function privilegedInvoker() {
  return restricted();
}
privilegedInvoker();

arguments.callee arguments.callee arguments.callee arguments.callee arguments.callee

js
"use strict";
function f() {
  return arguments.callee;
}
f(); // TypeError 

JavaScript

  • implements
  • interface
  • let
  • package
  • private
  • protected
  • public
  • static
  • yield

"use strict"

'use strict'; SyntaxError

  • 8 const n = 023;
  • with
  • delete delete myVariable
  • eval arguments
  • : implements, interface, let, package, private, protected, public, static, yield
  • 2 function f(a, b, b) {}
  • {a: 1, b: 3, a: 7} 1041128

JavaScript

this

f() w this undefined call apply this undefined null

arguments

arguments JavaScript arguments arguments

eval

eval eval

ECMAScript 2027 LanguageSpecification


Web Proxy Viewer  |  New URL  |  Original Page