function foo() { x = 10; } foo(); console.log(x); // 10
'use strict';
를 추가한다(function() { var let = 10; // non-strict mode에서는 에러가 발생하지 않음 function foo() { 'use strict'; let = 20 // syntaxError } foo(); };)()
(function () { 'use strict'; x = 10; console.log(x); // ReferenceError })()
(function () { 'use strict'; x = 10; delete x; // SyntaxError })()
(function () { 'use strict'; // SyntaxError function foo(x, x) { return x + x; } console.log(foo(1, 2)); })()
(function () { 'use strict'; // SyntaxError with({x: 1}) { console.log(x); } })()
function foo(a) { 'use strict'; a = 2; console.log(arguments); // {0: 1, length: 1} } foo(1);