1

First question: Are variables and functions in function declaration hoisted at the same time with global variables and functions or in creation phase of local execution context? And if answer is second, how it works?

If I'm right, (global) hoisting happens after parsing and before interpreter starts.

Second question: How hoisting of variables and functions in function expression works?

Thanks In Advance!

MSt
  • 11
  • 1
  • Not sure I fully understand your question, but see here for an example of locally-scoped variables and their effect on identically-named, globally-declared variables- https://stackoverflow.com/questions/15311158/javascript-hoisting. TL;DR- variables declared within the scope of a function do not override globally-declared variables with the same name, whether they're hoisted or not. – Richie Thomas Jun 18 '18 at 17:21
  • I clearly understand hoisting and lexical scope in JS. I'm interested in **how it works under the hood**. I know how it works under the hood for global variables and functions. – MSt Jun 18 '18 at 18:47
  • When **engine** hoists variables and functions in some function declaration or function expression? – MSt Jun 18 '18 at 18:55

0 Answers0