let’s get abstract with javascript

Michael Scoggins
2 min readJul 27, 2020

--

  1. Describe one thing you’re learning in class today.

i learned how higher order functions work, and how to design them from scratch using a vanilla for loop. i learned that higher order functions use more basic functions such as .pop() and .push() (such as .filter() ) to carry out their jobs.

2. Can you describe the main difference between a forEach loop and a .map() loop and why you would pick one versus the other?

a forEach() loop will simply run a function on each item inside an array, thereby possibly mutating that array permanently (and always return “undefined”). a .map() loop on the other hand will return a new array after passing through some function, thereby creating a “transformed array.” obviously very useful.

3. Describe event bubbling.

event bubbling is the property of eventListeners that determines whether it will “bubble up” to parent elements if it is not itself assigned the event. so that it will keep bubbling up until it finds its target, or else “pop” once it gets to the window object. what i don’t understand is how an event wouldn’t find its target in the first place.

4. What is the definition of a higher-order function?

a higher-order function is a function which has as at least one of its arguments another function. it’s really that simple!

5. ES6 Template Literals offer a lot of flexibility in generating strings. Can you give an example?

let greeting= “hello world

console.log(`the variable “greeting” can be invoked “literally” by doing this: ${greeting} so that i could, inside a string, say “one of the more common phrases used in web development is ${greeting}” and it would display the variable’s “literal” value: hello world`)

6. What Is an associative array in JavaScript?

ok here goes (and this might be misguided): in JS all arrays are objects. objects however, are not arrays. But, they are sometimes referred to as “associative arrays,” because they contain key-value pairs that are “associated” with one another.

7. Why should you never use new Array in JavaScript?

because there is literally no reason to. just say let array = [1,2,3] and boom you have a “new array” with that same “new Array” smell.

--

--

Michael Scoggins
Michael Scoggins

Written by Michael Scoggins

graduate of Austin Coding Academy. looking for a full-stack (MERN... with a flexible M) web dev position.

No responses yet