Last active
December 22, 2015 03:19
-
-
Save srkmrs/6409678 to your computer and use it in GitHub Desktop.
Use Strict
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| By marking the top of the script block or function with the "use strict” directive, the compiler will provide early warnings and errors for common coding mistakes, and restrict the usage of some dark corners of the JavaScript language. | |
| Let you see how the following sample code interact with Strict Mode. | |
| Code | |
| "use strict"; | |
| a = 100; | |
| b = 200; | |
| document.write(a + b); | |
| Results | |
| Error was detected; no results were produced. | |
| Errors | |
| Uncaught ReferenceError: a is not defined | |
| Expected Code | |
| "use strict"; | |
| var a = 100; | |
| var b = 200; | |
| document.write(a + b); | |
| Results | |
| 300 | |
| Errors | |
| No errors. | |
| (Note that Strict Mode is still under development in many browsers.) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment