JS211 blog week 4

Austin Skrobarczyk
2 min readSep 2, 2020
  1. Describe one thing you’re learning in class today.
    We worked on reduce() which executes a reducer function (that you provide) on each element of the array.
  2. Can you describe the main difference between a forEach loop and a .map() loop and why you would pick one versus the other?
    Well forEach iterates through each item and does something to it in turn mutating the original array. Map creates a new array with the results of calling a provided function on every element in the calling array.
  3. Describe event bubbling
    Event bubbling occurs when a user interacts with a nested element and the event propagates up (“bubbles”) through all of the ancestor elements.
  4. What is the definition of a higher-order function?
    Functions that operate on other functions, either by taking them as arguments or by returning them.
  5. ES6 Template Literals offer a lot of flexibility in generating strings. Can you give an example?
    `Hello ${personName}, we hope you enjoy your ${favStore} coupon.`
  6. What Is an associative array in JavaScript?
    JavaScript does not support associative arrays.
  • You should use objects when you want the element names to be strings (text).
  • You should use arrays when you want the element names to be numbers.

7. Why should you never use new Array in JavaScript?
It helps with consistency and The array literal notation is faster and also easier to read.

  • You should use objects when you want the element names to be strings (text).
  • You should use arrays when you want the element names to be numbers.

7. Why should you never use new Array in JavaScript? Answer: it overcomplicates the code, and it can lead to unexpected results.

--

--