| Method | Runs through each item | Executes Given Function | Returns the result | Number of elements in result (compared to original array) |
|---|---|---|---|---|
| .map | ✔ | ✔ | in array | = |
| .filter | ✔ | ✔ | if true, in array | =< |
| .forEach | ✔ | ✔ | no, return is undefined |
none |
| .reduce | ✔ | ✔ | in array or anything else | one, (a single number or string) Reduce transforms array into something else |
| for loop | ✔ | until condition is false, you know the number of iteration beforehand |
They run code blocks, They aren't functions so don't need to return | >, = or < |
| while loop | ✔ | while condition is true, you don't know the number of iteration beforehand |
They run code blocks, They aren't functions so don't need to return | >, = or < |
Created
July 7, 2023 21:03
-
-
Save ratulkuri/3632aad269c7621bc516f345f05b15be to your computer and use it in GitHub Desktop.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment