For instance:
https://memorize.ai/d/jT6p_r2rkR/web-development-interview-questions
FRONT: "What is variable hoisting in JavaScript? What are the issues that can arise with this?"
BACK: "Variables and functions may be available before they are declared. The javascript [sic] interpreter looks ahead to all variables that are to be declared in a function and hoists them to the top. Problems occur when you have variables of the same name inside and outside of a function."
I tested this:
console.log(derp);
const derp = 16;
And it gave me this:
console.log(derp);
^
ReferenceError: Cannot access 'derp' before initialization
at Object.<anonymous> (C:\Users\Choppy\Documents\Clutter\Coding\practice\hoisting\index.js:1:13)
at Module._compile (internal/modules/cjs/loader.js:1133:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:1153:10)
at Module.load (internal/modules/cjs/loader.js:977:32)
at Function.Module._load (internal/modules/cjs/loader.js:877:14)
at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:74:12)
at internal/main/run_main_module.js:18:47
It only semi worked with var, but then it logged undefined.
Hoisting for variables works differently than for functions, and it'd be cool to suggest this to the creator.
For instance:
https://memorize.ai/d/jT6p_r2rkR/web-development-interview-questions
FRONT: "What is variable hoisting in JavaScript? What are the issues that can arise with this?"
BACK: "Variables and functions may be available before they are declared. The javascript [sic] interpreter looks ahead to all variables that are to be declared in a function and hoists them to the top. Problems occur when you have variables of the same name inside and outside of a function."
I tested this:
And it gave me this:
It only semi worked with
var, but then it loggedundefined.Hoisting for variables works differently than for functions, and it'd be cool to suggest this to the creator.