Skip to content

Instantly share code, notes, and snippets.

@ChristianRich
Created July 21, 2022 15:10
Show Gist options
  • Save ChristianRich/70b58ff4b8f6b98ac81d054a41cd466b to your computer and use it in GitHub Desktop.
Save ChristianRich/70b58ff4b8f6b98ac81d054a41cd466b to your computer and use it in GitHub Desktop.
Array methods at a glance
// 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