-
Describe some of the differences between .forEach & .map.
.foreachexecutes a callback function on each element within an array and returns undefined. While.mapalso calls a callback on each element, it does not mutate the original array; instead, it returns a new array based on the results of the callback function..mapis favored in functional programming as it leaves the original array unchanged. -
Name five different Types in JavaScript. A Type is something that can represent data. What is so special about Arrays?
- Booleans
trueorfalse - Strings
'this is a string' - Numbers
20 - Objects
- Arrays - Arrays can contain any type including other arrays and there is no limit to the number of items you may store within. Arrays also have methods and properties built-in that allow you to quickly transform data.
- Booleans
-
What is closure? Can you code out a quick example of a closure?
A closure is a function inside of a function that has access to the outer function's variables.
const counter = () => { let count = 0; return () => { count++; return count; }; }; const myCounter = counter(); console.log(myCounter());
-
Describe the four rules of the 'this' keyword. No need to provide examples about it this time :)
- Window Binding - Functions on the global scope that contain
thiswill be referring to the window object - Implicit Binding - When dot noation is utilized to invoke a function, whatever left of the dot becomes the context for
this - Explicit Binding - Explicity setting
thisis bound to via.call,.apply, or.bind - New Binding - When
thisis used in an object constructor.
- Window Binding - Functions on the global scope that contain