1. 2
    Refactoring: Array.prototype by example [filter, some, forEach]
    5m 42s

Refactoring: Array.prototype by example [filter, some, forEach]

Erik Aybar
InstructorErik Aybar

Share this video with your friends

Send Tweet

Refactoring is a great opportunity to learn and we have an existing Javascript function that is lengthy, hard to understand, and overcomplicated. We'll take a look at putting some of Javascript's built in Array.prototype methods to use to help us clean this up and learn by example through refactoring.

By taking a few minutes to refactor this existing code, we can get a glimpse at how we can harness the power of the Array and lean on some built in Array functions available to us in Javascript's core without any added utility libraries.

In this lesson we touch on just a few of the Array methods:

Richard
Richard
~ 6 years ago

Much more elegant code I admit but if efficiency is a concern... well, seeing the test executions go up from 0.3 to 0.9 concerns me a little.

Ihor
Ihor
~ 5 years ago

Richard, are you talking about that line where console.log(Math.random()) is ? :)