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:
- 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. - place the
"use strict";
directive at the beginning of the script. - place the
"prevent undeclared variables";
directive at the beginning of the script.
Answers Explanation & Hints:
To treat writing to an undeclared variable as an error in JavaScript, you would need to place the So the correct option is: place the "use strict"; directive at the beginning of the script. By using the |