Because most of us know what are the differences between let const and var I would like to go a bit deeper and talk about what I have learned while studying how this simple code block gets evaluated "var foo = 'bar';".
Javascript is a compiled language with these 3 layers
- Engine: Responsible of compilation and execution, entire start to end life of the program.
- Compiler: Parses the given tokens and generates the code to be read by machine.
- Scope: Contains the lookup schema/list for all the declarations also creates accessablity map and rules for declarations
Keeping this information in mind lets return to our starting point "var foo = 'bar';". Whenever this statement is evaluated engine kicks the compiler in and parser starts parsing the statement to bits like 'var', 'foo', '=', "'bar'", ';'.
Temporal dead zone
Thats it, thanks for listening :)
03.06.2018 - Ören Aksakal - Warsaw