| [ Web Proxy ] |
| Viewing: https://developer.mozilla.org/ja/docs/Web/JavaScript/Reference/Strict_mode | [Back] [Original] |
Get to know MDN better
"use strict"; ( 'use strict';)
//
"use strict";
const v = "";
"use strict"; ( 'use strict';)
function myStrictFunction() {
//
"use strict";
function nested() {
return "";
}
return ` ${nested()}`;
}
function myNotStrictFunction() {
return "";
}
function sum(a = 1, b = 2) {
// SyntaxError: "use strict" not allowed in function with default parameter
"use strict";
return a + b;
}
function myStrictFunction() {
//
}
export default myStrictFunction;
class C1 {
//
test() {
delete Object.prototype;
}
}
new C1().test(); // TypeError test()
const C2 = class {
//
};
//
delete Object.prototype; //
eval arguments JavaScript
"use strict";
let mistypeVariable;
// mistypeVarible
// "mistypeVariable"
// "a" ReferenceError
mistypeVarible = 17;
3
NaN NaN NaN
"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
"use strict";
delete Object.prototype; // TypeError
delete [].length; // TypeError
delete name
"use strict";
var x;
delete x; // syntax error
"use strict";
delete globalThis.x;
function sum(a, a, c) {
//
"use strict";
return a + a + c; //
}
0 8 8 0644 0 8 8 (0644 === 420) 8
"use strict";
const sum =
015 + //
197 +
142;
8 0o
const sumWithOctal = 0o10 + 8;
console.log(sumWithOctal); // 16
8 ASCII "%" "\45" 8 \ 0 \0 \9 \07
"use strict";
false.true = ""; // TypeError
(14).sailing = "home"; // TypeError
"with".you = "far away"; // TypeError
SyntaxError ECMAScript 2015
"use strict";
const o = { p: 1, p: 2 }; // ECMAScript 2015
:
X JavaScript JavaScript
with with with with
"use strict";
const x = 17;
with (obj) {
//
// const x
// obj.x
//
//
x;
}
with
eval eval("var x;") x eval eval eval eval
var x = 17;
var evalX = eval("'use strict'; var x = 42; x;");
console.assert(x === 17);
console.assert(evalX === 42);
eval() eval() eval eval
arguments eval eval arguments eval arguments
eval arguments
"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 arg arg arguments[0] arguments[0] arguments arguments[i]
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
this this this this this this undefined null this callapplybind JavaScript this globalThis undefined
"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
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
"use strict";
function f() {
return arguments.callee;
}
f(); // TypeError
"use strict"
'use strict'; SyntaxError
const n = 023;with delete delete myVariableeval arguments implements, interface, let, package, private, protected, public, static, yieldfunction f(a, b, b) {}{a: 1, b: 3, a: 7} 1041128JavaScript
ReferenceError globalThis TypeError TypeError arguments.calleestrictFunction.callerstrictFunction.arguments TypeError arguments.callee | ECMAScript 2027 LanguageSpecification |
| Web Proxy Viewer | New URL | Original Page |