Put this at the top of your script files when you are not using any build tools and reap benefits.
There are actually a lot of things that this declaration does, but here are some.
Many modern JS environments have this enabled by default, or similar rules in place.
'use strict';
value = 42; // throws ReferenceError'use strict';
function fn (a) {
a = 42; // throws
}'use strict';
var o = { p: 1, p: 2 }; // !!! syntax errorYou can use 'use strict' within function scope.
(function() {
'use strict';
false.true = ''; // TypeError
(14).sailing = 'home'; // TypeError
'with'.you = 'far away'; // TypeError
})();'use strict';
var x;
delete x; // !!! syntax error
eval('var y; delete y;'); // !!! syntax error