Skip to content

Instantly share code, notes, and snippets.

@6ui11em
Created April 18, 2018 20:28
Show Gist options
  • Save 6ui11em/5a2af6b49eaada64328465d7450efd90 to your computer and use it in GitHub Desktop.
Save 6ui11em/5a2af6b49eaada64328465d7450efd90 to your computer and use it in GitHub Desktop.
Javascript array map #javascript #array
var numbers = [1, 4, 9];
var doubles = numbers.map(function(num) {
return num * 2;
});
// Logs [2, 8, 18]
console.log(doubles);
var data = [
{
name: 'Kyle',
occupation: 'Fashion Designer'
},
{
name: 'Liza',
occupation: 'Web Developer'
},
{
name: 'Emily',
occupation: 'Web Designer'
},
{
name: 'Melissa',
occupation: 'Fashion Designer'
},
{
name: 'Tom',
occupation: 'Web Developer'
}
];
var names = data.map(function (item) {
return item.name;
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment