Created
May 27, 2022 15:28
-
-
Save frivolta/ff2d33ceb27dc9bfbdb9922b5c7ff12c to your computer and use it in GitHub Desktop.
Write better React, compose multiple functional HoCs, Higher-Order Components - Array.prototype.map
This file contains 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
// Result is [2,3,4] | |
[1,2,3].map((number)=>number+1) | |
// Note that you can extract the callback function and pass it to the map function: | |
function addOne(arg){ | |
return arg+1 | |
} | |
[1,2,3].map((number)=>addOne(number)) | |
// or | |
[1,2,3].map(addOne) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment