Last Updated on December 1, 2015
Tells the browser, please add some extra rules when you parse and try to execute my code.
var people;
perple = {};
console.log(perple);
The result is:
Object {}
With "use strict";
the result is:
Uncaught ReferenceError: perple is not defined
"use strict" says, you must declare a variable in order to use it. Which can be really helpful when you have mistyped errors, similarly spelled functions or objects and get squirrelly responses.
TO USE:
It can be used at the top of your file OR at the top of a function and must be on the first line.
What it does: (from Stack Overflow) -
- It catches some common coding bloopers, throwing exceptions.
- It prevents, or throws errors, when relatively "unsafe" actions are taken (such as gaining access to the global object).
- It disables features that are confusing or poorly thought out.