Last active
November 2, 2017 10:50
-
-
Save amoghpalnitkar/cacbcae1c4a69894a8245a53305cdffc to your computer and use it in GitHub Desktop.
Helper for medium blog.
This file contains hidden or 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
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