MENU
General Restrictions
Strict Mode can be applied to an entire script by placing "use strict"; before any other statements in the script. Strict state is not shared across different scripts.
Strict Mode enforces the following:
Global variables cannot be declared without using a declaration keyword.
RESETRUNFULL
<!DOCTYPE html><html><body><script>
"use strict";a=10; // Reference Error
</script></body><html>
Non-writable properties cannot be deleted.
RESETRUNFULL
<!DOCTYPE html><html><body><script>
"use strict";//delete Object.prototype; // TypeErrordelete window.undefined; // TypeError
</script></body><html>
Octal syntax is not supported.
RESETRUNFULL
<!DOCTYPE html><html><body><script>
"use strict";var x = 0777; // Syntax Error
</script></body><html>
The keyword 'with' is not supported.
RESETRUNFULL
<!DOCTYPE html><html><body><script>
"use strict";var o = {a:3};with (o) var b=a; // Syntax Error
</script></body><html>
'eval()' cannot create variables in the surrounding scope.
RESETRUNFULL
<!DOCTYPE html><html><body><script>
"use strict";eval("var a=3;");console.log(a); // ReferenceError
</script></body><html>
'implements', 'interface', 'package', 'private', 'protected', 'public', 'static', 'let', and 'yield' are reserved keywords.
RESETRUNFULL
<!DOCTYPE html><html><body><script>
"use strict";//var let = 100; // SyntaxErrorvar implements = 200; // SyntaxError
</script></body><html>
Attempts cannot be made to extend a non-extensible object.
RESETRUNFULL
<!DOCTYPE html><html><body><script>
"use strict";var o = {};Object.preventExtensions(o);o.a =10; // TypeError
</script></body><html>
'eval' and 'arguments' cannot be bound or assigned.
RESETRUNFULL
<!DOCTYPE html><html><body><script>
'use strict';var eval = 17; // SyntaxErrorarguments++; // SyntaxError++eval; // SyntaxErrorvar obj = { set p(arguments) { } }; // SyntaxErrorvar eval; // SyntaxErrortry { } catch (arguments) { } // SyntaxErrorfunction x(eval) { } // SyntaxErrorfunction arguments() { } // SyntaxErrorvar y = function eval() { }; // SyntaxErrorvar f = new Function('arguments',
"'use strict'; return 17;"); // SyntaxError
</script></body><html>