DEV Community

Mrityunjay-Palled
Mrityunjay-Palled

Posted on

Playing With Array of Objects in JavaScript

Being a JavaScript programmer, it's always important to know how to deal with an array of objects. In our day-to-day programming, we all come across an array of objects in one way or another. For example, the data coming from an API is in a JSON format, which is pretty much similar to an array of objects. So, let's take a look at how we can play around with array of objects. Before continuing it's mandatory to have some basic knowledge of map(),filter(),reduce() methods. You can also refer my article on these methods

Image description

1.Getting All the Employees Names:

Image description

2.Getting All Employees Name Whose Salary Is 10000

Image description

3.Finding Sum of All Salaries:

Image description

4.Finding the Employees from The Same City and Increase Their Salary by 5000

Image description

5.Filter Employees by array of ids:

Image description

6.Let's take a look at how we can remove duplicate objects

Image description

In the above array of objects, we can see that we have two similar objects.one of them can be removed by using the following method

Image description

here we can see that when we log the result, we get the array of objects with no duplicates

Top comments (0)