Skip to content

Instantly share code, notes, and snippets.

View aquaductape's full-sized avatar
🐢
🐢🐢🐢🐢🐢🐢🐢🐢🐢🐢🐢🐢🐢🐢🐢🐢🐢🐢🐢🐢🐢🐢🐢🐢🐢🐢🐢🐢🐢🐢🐢🐢🐢🐢🐢🐢🐢🐢🐢🐢🐢🐢🐢🐢🐢🐢🐢🐢🐢🐢🐢🐢🐢🐢🐢🐢🐢🐢🐢🐢🐢🐢🐢🐢🐢🐢🐢🐢🐢🐢🐢🐢🐢🐢🐢🐢🐢🐢🐢🐢

Caleb Taylor aquaductape

🐢
🐢🐢🐢🐢🐢🐢🐢🐢🐢🐢🐢🐢🐢🐢🐢🐢🐢🐢🐢🐢🐢🐢🐢🐢🐢🐢🐢🐢🐢🐢🐢🐢🐢🐢🐢🐢🐢🐢🐢🐢🐢🐢🐢🐢🐢🐢🐢🐢🐢🐢🐢🐢🐢🐢🐢🐢🐢🐢🐢🐢🐢🐢🐢🐢🐢🐢🐢🐢🐢🐢🐢🐢🐢🐢🐢🐢🐢🐢🐢🐢
View GitHub Profile
https://repl.it/@CalebTaylor2/area-of-a-rectangle-drill
https://repl.it/@CalebTaylor2/temperature-conversion-drill
https://repl.it/@CalebTaylor2/Is-divisible-drill
https://repl.it/@CalebTaylor2/Traffic-lights-drill
https://repl.it/@CalebTaylor2/Error-alert-drill
https://repl.it/@thinkful/Array-length-and-access-drill
https://repl.it/@thinkful/Accessing-array-items-drill
https://repl.it/@thinkful/Adding-array-items-drills
https://repl.it/@thinkful/Array-copying-I-drill
https://repl.it/@thinkful/Array-copying-II-drill
https://repl.it/@thinkful/Squares-with-map-drill
https://repl.it/@thinkful/Sort-drill
https://repl.it/@thinkful/Filter-drill
https://repl.it/@thinkful/Find-drill
https://repl.it/@thinkful/min-and-max-without-sort-drill
https://repl.it/@thinkful/average-drill
https://repl.it/@thinkful/fizzbuzz-drill-js
1. What is scope?
Scope is where the variable can used. A variable declared globally means that it can accessed everywhere including in local scopes
such as functions or conditional statements.
2. Why are global variables avoided?
Global variables will overwrite other variables with the same binding name in local scopes such as functions. This will lead to
unintended results. To avoid this, inside the function, redeclare that binding name so that it is set in that local environment.
https://repl.it/@thinkful/Object-creator-drill
https://repl.it/@thinkful/Object-updater-drill
https://repl.it/@thinkful/Self-reference-drill
https://repl.it/@thinkful/Deleting-keys-drill
@aquaductape
aquaductape / mySort.js
Last active July 4, 2019 07:57
recreating array sort method
// Array prototype method, however this is not safe, since it is added to the global scope
// definedProperty makes method non-enumerable as well as adding new property to in this case, to Array prototype
// Array prototype method, however this is not safe, since it is added to the global scope
// definedProperty makes method non-enumerable as well as adding new property to in this case, to Array prototype
Object.defineProperty(Array.prototype, 'mySort', {
value: function(callback) {
const mergeSort = arr => {
if (arr.length === 1) {
return arr;
}
@aquaductape
aquaductape / JS_ARRAY_METHODS.md
Last active June 19, 2019 21:40
recreate common array methods that take higher order functions

Array.prototype.*

recreate common array methods that take higher order functions


Example

  • Array.prototype.myForEach = ...
  • Object.defineProperty(Array.prototype, 'myForEach', { value: ...

1. forEach

Syntax