#Map Operator adding alias

1 messages · Page 1 of 1 (latest)

vocal mirage
#

I'm trying to convert underscore library code to new angular

Original code

materials : _.map(this.materials, function (item) {
      return {
          InventoryItemNumber: item.product.ItemNumber,
          Quantity: item.quantity
      };
    })```

What I have so far
```ts

materials: this.materials.map((item: any) => {
        item.product.itemNumber,
        item.quantity
      }),```

I need to get those alias into the new code how can I do this?
blazing stump
#
materials: this.materials.map((item: any) => {
  // we return an object here
  return {
    InventoryItemNumber: item.product.itemNumber,
    Quantity: item.quantity
  }
});
#

short form would be:

materials: this.materials.map(item => ({
  InventoryItemNumber: item.product.itemNumber,
  Quantity: item.quantity
}));