Skip to content

Instantly share code, notes, and snippets.

@johnayoung
Created December 4, 2018 16:50
Show Gist options
  • Save johnayoung/04c92a17876f05e5b5ef7b8e69c63b75 to your computer and use it in GitHub Desktop.
Save johnayoung/04c92a17876f05e5b5ef7b8e69c63b75 to your computer and use it in GitHub Desktop.
John Young and Jordan Heffernan 'In your own words' exercise.

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

Scope is part of the reasoning of how code works in regards to variables. Global scope allows accessing variables everywhere, whereas local scope is bound to the block at which it is defined.

2. Why are global variables avoided?

Global variables are avoided to prevent unintended side effects.

3. Explain JavaScript's strict mode

'Strict mode' forces the declaration of variables. More specifically, strict mode looks for variables to be declared with let or const . If not, then the program will throw an error.

This can be accomplished by including a 'use strict' at the top of the JavaScript file.

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

Side effects are unintended consequences of a function. They occur when a function has effect outside of it's scope.

A pure function has no unintended side effects, and always produces a consistent output with the same parameters.

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