# Add an attribute to a json object using spread operator

> The Spread Operator is "..." three dots, which allows to extend an object. Code for adding attributes to an existing json object: You can also extend the same object also:

- Canonical: https://preview.arshadmehmood.com/today-i-learned/javascript/add-attribute-to-json-object-using-spread-operator/
- Section: javascript
- Author: Arshad Mehmood

The [Spread Operator](https://developer.mozilla.org/de/docs/Web/JavaScript/Reference/Operators/Spread_operator) is "..." *three dots*, which allows to extend an object.

Code for adding attributes to an existing json object:

```
var parts = ['shoulders', 'knees'];
var lyrics = ['head', ...parts, 'and', 'toes']; // ["head", "shoulders", "knees", "and", "toes"]
```

You can also extend the same object also:
```
parts =  [...parts, 'and', 'toes'];
```

