Skip to content

Instantly share code, notes, and snippets.

@yasirjanjua
Created May 27, 2017 17:18
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save yasirjanjua/767cac1f10888a59c87fd6a83457091f to your computer and use it in GitHub Desktop.
Save yasirjanjua/767cac1f10888a59c87fd6a83457091f to your computer and use it in GitHub Desktop.
What is scope? Your explanation should include the idea of global vs. local scope.
JavaScript has two scopes: global and local. A variable that is declared outside a function definition is a global variable, and its value is accessible and modifiable throughout your program. A variable that is declared inside a function definition is local
Why are global variables avoided?
Global variables are accessible through out the program and their value can be manipulated unwantedly which causes error. That is why global variables are avoided.
Explain JavaScript's strict mode
JavaScript strict mode changes silent mistakes to throw erroes.It doesn't allow any variable to get initialize without proper delaration.
What are side effects, and what is a pure function?
A pure function doesn't depend on and doesn't modify the states of variables out of its scope. Concretely, that means a pure function always returns the same result given same parameters.
Explain variable hoisting in JavaScript.
The behaviour of js interpreter to move the declarations to the top. Hence if the variable is used before its declaration within a scope . the interpreter will move the declraration to the top before variable is used
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment