Fichas
Array methods
Fichas del 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]
Información
- Descripción
- Array Fichas sobre Array methods, creado por milly larcen el 14/04/2020.
- Creado por
- milly larcen · abr 2020
- Actualizado
- 14 abr 2020
- Visitas
- 1
- Valoración