Filter an Array with Truthy Values

InstructorShane Osbourne

Share this video with your friends

Send Tweet

Array filter creates a new array with all elements that pass the test implemented by the provided function. In this lesson we discuss how only a truthy or falsey value is required as the return value to the function, which in turns allows us to be creative in how we perform the filter. We end the lesson by looking at an example showing how chaining multiple array methods together can lead to very nice, declarative code.

Robert Smith
~ 8 years ago

This might come under the realm of premature optimisation, but wouldn't it be better, instead of chaining together two filter methods to instead do both checks simultaneously inside of a single filter method?

I get the immense power that chaining provides and this demo illustrates that well, but we should be careful when doing this over very large data sets; of course in the provided example the difference would be negligible.

Johan Faerch
~ 5 years ago

I get undefined. Exception: ERROR_LOADING on this video :(

I can get around it by using VPN!??