Last active
January 23, 2023 17:07
-
-
Save ibuziuk/fd994471f5681ea64f74b4cb12c7f353 to your computer and use it in GitHub Desktop.
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
// map with arrow function | |
const names = ['Ilya', 'Alena', 'Nadia', 'Sasha']; | |
const members = names.map((name, index) => "member " + index + " " + name); | |
console.log(names); | |
console.log(members); | |
// map with function | |
const names = ['Ilya', 'Alena', 'Nadia', 'Sasha']; | |
const members = names.map(function(name, index) { | |
return "member " + index + " " + name; | |
}); | |
console.log(names); | |
console.log(members); | |
// map with function expression | |
const names = ['Ilya', 'Alena', 'Nadia', 'Sasha']; | |
const namesToMembers = function (name, index) { | |
return "member " + index + " " + name; | |
} | |
const members = names.map(namesToMembers); | |
console.log(names); | |
console.log(members); | |
// map with function declaration | |
const names = ['Ilya', 'Alena', 'Nadia', 'Sasha']; | |
function namesToMembers(name, index) { | |
return "member " + index + " " + name; | |
} | |
const members = names.map(namesToMembers); | |
console.log(names); | |
console.log(members); | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment