Somehow over halfway done…

Taylor Cannetti
2 min readNov 1, 2020

Sometimes I get stuck in the weeds of things and struggle to look at the broader problem being solved. These questions are helpful in bringing what we learn throughout the week to a more defined conclusion.

Describe one thing you’re learning in class today.

We learned about different methods find() and findIndex(). These are both useful at searching through object arrays, strings, or any other bit of data to find either specific strings, numbers, or in the instance of findIndex(), at finding the index position within an array that something occurs.

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

I’ll define both:

“The map() method creates a new array populated with the results of calling a provided function on every element in the calling array.”

forEach() calls a provided callback function once for each element in an array in ascending order.”

So forEach won’t exactly return anything, while map() creates a new array of the same size with return values.

So you’d probably use map() when you have information from an array that needs to be returned for a new instance. forEach would just allow you to callback a function on elements within the array to accomplish something greater in scope.

Describe event bubbling.

It’s a type of event propagation that triggers on the innermost target element, and then successfully triggers on each one up the chain until it reaches the outermost element of the DOM.

What is the definition of a higher-order function?

“A higher-order function is a function that can take another function as an argument, or that returns a function as a result.”

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

They allow for extra spacing which is useful in the case of adding long strings. It is separated by the `` back-ticks.

Example:

console.log('string text line 1\n' +
'string text line 2');
// "string text line 1
// string text line 2"

with template literals the same can be accomplish by removing the +

console.log(`string text line 1
string text line 2`);
// "string text line 1
// string text line 2"

What Is an associative array in JavaScript?

Associative arrays are basically objects in JavaScript where indexes are replaced by user defined keys. They do not have a length property like normal array and cannot be traversed using normal for loop.” This last sentence is because they are no longer an array, they have been transformed into an object if I understood.

Why should you never use new Array in JavaScript?

It seems to be too ambiguous and becomes an issue when memory is of importance.

--

--