Skip to content

Instantly share code, notes, and snippets.

@jamessergeant
Created August 9, 2017 13:08
Show Gist options
  • Save jamessergeant/7a5ecc3b439bf2556d42bd7f0aee8b54 to your computer and use it in GitHub Desktop.
Save jamessergeant/7a5ecc3b439bf2556d42bd7f0aee8b54 to your computer and use it in GitHub Desktop.

What is scope? Your explanation should include the idea of global vs. local scope.

Scope determines where a variable can be accessed. A variable with local scope can only be accessed within that function. A variable with global scope can be accessed anywhere unless it's variable name is shadowed by a local variable.

Why are global variables avoided?

To avoid unexpected or indeterminate behaviour.

Explain JavaScript's strict mode

Strict mode forces a variety of conventions including the use of the var keyword when declaring variables.

What are side effects, and what is a pure function?

Side effects are unexpected behaviours due to modifying global variables. A pure function only uses local variables.

Explain variable hoisting in JavaScript.

Hoisting is due to the code parsing shifting the declaration of variables and functions to the beginning of the function or script, respectively.

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