By default, JavaScript allows us to write to an undeclared variable (it declares it implicitly for us). If we want the interpreter to treat such a situation as an error, we have to:
- place the “use strict”; directive at the beginning of the script.
- place the “prevent undeclared variables”; directive at the beginning of the script.
- perform all writes to variables in a block of code delimited by braces.
- place the “use strict”; directive before each write we want to protect.
More Questions: JavaScript Essentials 1 – JSE1: Module 2 Test
Please login or Register to submit your answer