Created
October 21, 2019 15:35
-
-
Save epjuan21/07a230fa6bda248dd4d2900c1858cbaa to your computer and use it in GitHub Desktop.
Map array without .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
// Map array without .map() | |
var friends = [ | |
{ name: ‘John’, age: 22 }, | |
{ name: ‘Peter’, age: 23 }, | |
{ name: ‘Mark’, age: 24 }, | |
{ name: ‘Maria’, age: 22 }, | |
{ name: ‘Monica’, age: 21 }, | |
{ name: ‘Martha’, age: 19 }, | |
] | |
var friendsNames = Array.from(friends, ({name}) => name); | |
console.log(friendsNames); // returns [“John”, “Peter”, “Mark”, “Maria”, “Monica”, “Martha”] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment