To refresh for interviews and such

closure

How a function retains access to the to its outer function’s variables, even after the outer function has finished executing. So, global variables can be made local with closures.

Problem in React - stale closures.

Note which I did not know: undeclared variables are global by default:

function myFunction() {
  a = 4;
}

hoisting

Using a variable before declaring it. Focus on “declaration” - not initialization, and “variable” - meaning the globally accessible var and not let and const.

How does this happen? Variable and function declaration are moved to the top of their scope during compilation, before execution in JavaScript. Good practice still, to avoid bugs, is to declare the variables before using them (like a normal person).

To take more notes on:

What is the difference between a promise and a callback?

this keyword,

Prototypes,

Async-style code,

Promises,

Timers (setTimeout(), setInterval())

JavaScript design patterns: Observer pattern, Module pattern

HTML: Event delegation (it was useful in almost every interview),

DOM traversal

DOM manipulation