The closure is considered to be the inner function that has access to the variables of the outer function. Every time when executing the outer function, the instance of the inner function containing new references to variables of the outer function is created. Thanks to closure, the inner function remembers all the variables passed to the inner function. Read more
Use strict mode
The “use strict” directive changes code into the mode that adheres to the up-to-date standard. It looks like the line “use strict” or ‘use strict’ and is placed at the beginning of the script:
1 2 |
"use strict"; // code JavaScript |
Besides, the directive is used in functions. In such cases, a strict mode can be executed in function scope. The action “use strict” can’t be possibly canceled. It’s not supported by versions IE9 and older.
Read more