ForEach() is a high level method that very much acts like map() but with a few key differences. Like map(), forEach iterates over each item in an array and applies a function to said item.

let arrayOfNums = [1, 2, 3, 4]arrayOfNums.map(num => return num * num)
//=> returns [1…

Ah Arrays, the big grand daddy of data structures. Truth be told you’ll probably use arrays more than any other data structure that you’ll ever come across, they are just that useful!

In concept arrays are pretty simple, they are just an ordered list of values. For example:

let simpleArray…

Reduce is another higher-order function that is available in most programming languages. You can think of reduce as a function that takes in multiple elements in the form of an array, and ‘reduces’ them into one value.

For example lets say we have an array of numbers:

const numArray = [1, 4, 6, 11]

And you wanted to get the sum of all the numbers in the array. With reduce() we can perform this task in a neatly written function:

// accumulator acts as a starting point for our reducer 
// when we enumerate over our array, the function's results
// are "accumulated" at starting position
// currentValue keeps track of the current value the enumeration
// is happening on
numArray.reduce((accumulator, currentValue) => {
return accumulator + currentValue
});
//=> 22

This gives you a single value which all of the have been “reduced” to.

Map is a higher-order function that is available in most programming languages. Very simplistically you can think of map as a function that applies another function to all elements fed into it, and then is spits out an new array filled with the results of changed elements.

For example lest…

Constant time is usually considered the fastest time complexity when it comes to big o notation. The reason being that regardless of how much input goes into the algorithm it performs the same amount of computations every time.

An example of how this works is, you are part of political…

Dean

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store