Worklog 062018 – New JavaScript Array Methods

Still lots of general setup-y stuff today, but I did learn a few things.

New JavaScript Array Methods

I was listening to this episode of Syntax on the way to work this morning, and learned some tasty new JS array methods.

I made a CodePen for code examples.

See the Pen JavaScript Arrays – .some(), .includes(), .from() by J.C. Hiatt (@jchiatt) on CodePen.dark


.some() tests whether at least one element in the array passes the test you provide as a callback function. Note that it immediately returns as soon as it finds the first true value, so it has no idea if there are multiple elements within the array that would pass true. It only cares that there’s at least one.


.includes() checks whether the array includes a specific value you pass in, returning true or false.


.from() creates a new array from an array-like or iterable object. Note that it only creates a shallow copy, so nested values aren’t copied. You can also pass in an optional map function to call on every element of the array as it is added.

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.