-
-
Save ChristianRich/70b58ff4b8f6b98ac81d054a41cd466b to your computer and use it in GitHub Desktop.
Array methods at a glance
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// The filter() method creates a new array filled with elements that pass a test provided by a function | |
[1, 2, 3, 4, 5].filter((n) => n > 3); // [4,5] | |
// The find() method returns the value of the first element that passes the test | |
[1, 2, 3, 4, 5].find((n) => n > 3); // 4 | |
//. The every() method tests whether all elements in the array pass the test implemented by the provided function. It returns a Boolean value. | |
[1, 30, 39, 29, 10, 34].every((n) => n < 40); // true |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment