Skip to content

Instantly share code, notes, and snippets.

@orenaksakal
Last active September 30, 2018 14:36
Show Gist options
  • Save orenaksakal/7a6cd51a1e7463e58533b9387d5ddf41 to your computer and use it in GitHub Desktop.
Save orenaksakal/7a6cd51a1e7463e58533b9387d5ddf41 to your computer and use it in GitHub Desktop.

Let & Const in ES6

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';".

Quick info

Javascript is a compiled language with these 3 layers

  1. Engine: Responsible of compilation and execution, entire start to end life of the program.
  2. Compiler: Parses the given tokens and generates the code to be read by machine.
  3. 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'", ';'.

What is a variable ?

What is a scope ?

Let it be;

Const for Constant;

What is different in between var, const, let;

WATCHOUTS;

Temporal dead zone

Thats it, thanks for listening :)
03.06.2018 - Ören Aksakal - Warsaw

Sources you may find useful;

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment