I am beginner for javascript, there's a function call that the syntax I don't understand:
Suppose I have a list of products and each product has id 1,2..
export default class ItemRoute extends Route {
model(params) {
const { item_id } = params;
const product = products.find(({ id }) => id === item_id);
return product;
}
}
I am confused: what is ({ id }) => id doing? Is this another function like: function getId(id) and it returns the id?, why we can't directly doing like that: product.find(id === item_id)?
Aucun commentaire:
Enregistrer un commentaire