---
description: >-
  https://stackoverflow.com/questions/39827087/add-key-value-pair-to-all-objects-in-array
---

# Add key value pair to all objects in array (ok)

I wanted to add a key:value parameter to all the objects in an array.

eg:

```javascript
var arrOfObj = [{name: 'eve'},{name:'john'},{name:'jane'}];
```

I wanted to add a key:value parameter to all the objects in an array.

eg:

```javascript
var arrOfObj = [{name: 'eve'},{name:'john'},{name:'jane'}];
```

Now I wanted to add a new parameter, isActive to all the objects so the resulting array will look like.

eg:

```javascript
    [{
    name: 'eve',
    isActive: true
}, {
    name: 'john',
    isActive: true
}, {
    name: 'jane',
    isActive: true
}]
```

```javascript
const newArr = [
  {name: 'eve'},
  {name: 'john'},
  {name: 'jane'}
].map(v => ({...v, isActive: true}))
```
