In this blog, your going to see how to use .map() functions in Angular. I will explain to you how it works with a simple example.
You have received an array containing multiple objects, each one representing an employee detail. You need to retrieve the id of each employee in an array object.
- // What you have
- var employees = [
- { id: 11, name: 'Ravishankar' },
- { id: 12, name: 'Muthu' },
- { id: 13, name: 'Mani' },
- { id: 14, name: 'Ajith' }
- ];
- // What you need
- [11, 12, 13, 14]
You can achieve this using .map()like below.
- var employeeIds = employees.map(employee => employee.id);
That’s it. I hope you have learned how to use .map() in Angular.

Deepak KelathPosted Dec 20, 2020, 9:01 AM
Good and simple