Javascript variables

From wikinotes

Variable Scope

execute-context-scoped:  # variable scoped to function, or module if not defined in function
block-scoped:            # variable scoped to the { ... } contents

Declaration & Assignment

var foo          // declare var (execute-context-scoped)
let foo          // declare var (block-scoped)
const foo        // declare constant (read-only) (block scoped)

var foo = "bar"  // declare/assign variable (execute context scoped)
let foo = "bar"  // declare/assign variable (block scoped)
var foo = (foo === undefined) ? "default" : foo  // assign if undefined