Stay One Step Ahead
Explore how to stay ahead of JavaScript gotchas by applying the 'use strict' directive. Understand the scope and syntax of strict mode and how it helps prevent errors such as undeclared variables, protecting your code from subtle bugs.
The traps we saw in the previous lesson have been part of JavaScript for a long time. Even though the language has evolved considerably, these gotchas are inherent, and they’re here to stay. Thankfully, we can make a preemptive strike to avert these issues using some tools and techniques.
Apply the use strict directive
Placing 'use strict'; at the beginning of a JavaScript source file or within a function turns on the strict mode of execution.
In ...