Skip to content

Instantly share code, notes, and snippets.

@ievgenk
Created February 5, 2018 03:31
Show Gist options
  • Save ievgenk/6bb2d4b600927ec9c6b69523ee8412cc to your computer and use it in GitHub Desktop.
Save ievgenk/6bb2d4b600927ec9c6b69523ee8412cc to your computer and use it in GitHub Desktop.
Challange: In your own words
What is scope? Your explanation should include the idea of global vs. local scope.
To me scope is the rule set within which variables can be accessed by the functions. Global scope means that variables can be accessed and modified from anywhere withi hte code, and even another JS file. Whereas local scope varialbes can be modified and achieived only within the code block that they are located within.
Why are global variables avoided?
They are to be avoided due to possiblle unintentional side effects that can be caused by modifying the global variables. Some of these side effects can lead to bugs that will be hard to trace and fix, especially in a larger code base.
Explain JavaScript's strict mode
Stricti mode will enforce programmer using 'let' and 'const' declarations which in turn will ensure that no variable have global scope.
What are side effects, and what is a pure function?
Side effects are uninteded results that are usually caused by using or modifying global variable. And pure function is a function that does not create any undisarable side effects and has a predictable outcome everytime.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment