Skip to content

Instantly share code, notes, and snippets.

@spoccomp
Created June 27, 2018 21:30
Show Gist options
  • Save spoccomp/daf5d0b9afb2525a78bf1d4ccc43f586 to your computer and use it in GitHub Desktop.
Save spoccomp/daf5d0b9afb2525a78bf1d4ccc43f586 to your computer and use it in GitHub Desktop.
Challenge: In your own words
What is scope? Your explanation should include the idea of global vs. local scope.
JS reads code from top to bottom and left to right. Global scope is anything that is not in a function or a block and therefore can be used
globally. Where local scope is confined to functions and blocks and therefore encapsulated in those functions or blocks from the Global scope
Why are global variables avoided?
Global variables should be avoided because of control, it can be lost in which unintended consequences can resul in the program.
Explain JavaScript's strict mode
Strict mode is used to keep the developer on tract with their code when dealing with variables. It also can be used for functions and other
items in JS that I am unfamilar with but in essence strict mode or 'use strict' tests in the background for sloppy coding when it comes to variables.
What are side effects, and what is a pure function?
Side effects can be related to global and local scope when a function mutates them. A pure function should not do this. It should return whatever
the function was built for. I am not sure this can be done with complex programs, but I am a novice.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment