The ability to reply to discussions is limited to PRO members. Want to join in the discussion? Click here to subscribe now.

Array.prototype.reduce in JavaScript by example

Array.prototype.reduce in JavaScript by example

4:49
Let's take a closer look at using Javascript's built in Array reduce function. Reduce is deceptively simple and when harnessed correctly can achieve very powerful results. By leveraging reduce, we can answer a variety of questions on a single, simple data set. In this lesson, we'll look at how you might use [Array.prototype.reduce](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/Reduce) to: - Sum an array of numbers - Reduce an array of objects to a sum of a given property - Group an array of objects by key or a set of given criteria - Count the number of objects in an array by key or a given set of criteria
Watch this lesson now
Avatar
egghead.io

Let's take a closer look at using Javascript's built in Array reduce function. Reduce is deceptively simple and when harnessed correctly can achieve very powerful results. By leveraging reduce, we can answer a variety of questions on a single, simple data set. In this lesson, we'll look at how you might use Array.prototype.reduce to:

  • Sum an array of numbers
  • Reduce an array of objects to a sum of a given property
  • Group an array of objects by key or a set of given criteria
  • Count the number of objects in an array by key or a given set of criteria
Avatar
Alex

i wonder what is this editor that you use to produce your episodes? You all seem to use different editors, unless it is different settings of WebStorm?

Avatar
Erik

Hi Alex,

For this episode (and many others) the editor is JSBin. It looks like the JSBin link is broken, but you can view and play with the source/editor for this lesson here: http://jsbin.com/sapafe/latest/edit?js,console

We do tend to use a variety of editors since different lessons have different requirements and as instructors we have our own preferences. JSBin is great for small prototypal stuff and has great ES6/Babel support.

Personally, I use WebStorm combined with SublimeText day-to-day (you can peak at my Sublime setup here: https://egghead.io/lessons/ecmascript-6-es6-modules-es2015-import-and-export and my WebStorm setup here: https://egghead.io/lessons/misc-webstorm-installing-custom-color-schemes-dayleress-colour-schemes)

In reply to Alex
Avatar
Alex

jsbin is pretty cool. I did not know about it. thanks.

In reply to Erik
HEY, QUICK QUESTION!
Joel's Head
Why are we asking?