Skip to content

Instantly share code, notes, and snippets.

@amoghpalnitkar
Last active November 2, 2017 10:50
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save amoghpalnitkar/cacbcae1c4a69894a8245a53305cdffc to your computer and use it in GitHub Desktop.
Save amoghpalnitkar/cacbcae1c4a69894a8245a53305cdffc to your computer and use it in GitHub Desktop.
Helper for medium blog.
const cars = [
{
name : "BMW",
color : "blue",
logo : "bmw_logo.png",
type : "Sedan"
},
{
name : "Mercedes",
color : "black",
logo : "merc_logo.png",
type : "Sedan"
}
//and so on..
]
//using for-loop.
let carNames = [];
for(let i = 0 ; i < cars.length ; i++) {
carNames.push(cars[i].name);
}
//vs
//using map method
const carNames = cars.map((car) => car.name);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment