Skip to content

Instantly share code, notes, and snippets.

@johnfkneafsey
Created November 22, 2016 15:47
Show Gist options
  • Save johnfkneafsey/ce841da9217c712fb33760faffc7c102 to your computer and use it in GitHub Desktop.
Save johnfkneafsey/ce841da9217c712fb33760faffc7c102 to your computer and use it in GitHub Desktop.
In my own words
What is scope? Your explanation should include the idea of global vs. local scope.
Scope is a term used to classify parts of your code that have access to a variable. If the scope of the variable is local, any code inside the function can access the variable. Any code outside the function cannot. If the scope of a variabel is global, it means that the variable can be accessed from anywhere.
Why are global variables avoided?
Global variables can be bad for a variety of reasons- they make it difficult to work collaboratively, they can lead to bugs in your code that are difficult to untangle, you can run into concurrency issues, you may confuse global and local variable names, and so on.
Explain JavaScript's strict mode
JS's strict mode disables the use of global variables, forcing the user to define all variables locally.
What are side effects, and what is a pure function?
Side effects are pieces of code whereby a variable is created and available throughout a scope when it doesn't need to be. Pure functions are functions that don't depend on or modify variables outside of its scope.
Explain variable hoisting in JavaScript.
Hoisting is JS's default behavior of moving all declarations to the top of the current scope, allowing variables to be declared after they are used.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment