Flashcards
Array methods
Flashcards do conjunto (2)
- 1forEach()data.forEach(function(item, index, array) {
console.log(item.id, item.title);
});
When data is array, `item` is the array item; `index` is the array item index; and the last argument, `array`, is the original array. So, for every item in array, this function will be executed once. - 2map()`map()` method returns a new array
var products = [{
id: 0, name: 'Product 1'},{
id: 1, name: 'Product 2'}];
var productsIds = products.map(
product => product.id);
console.log(productsIds); // [0, 1]
Informações
- Descrição
- Array FlashCards sobre Array methods, criado por milly larcen em 14-04-2020.
- Criado por
- milly larcen · abr 2020
- Atualizado
- 14 abr 2020
- Visualizações
- 1
- Avaliação