# Object Literal Property Value Shorthand

It is common to create JavaScript objects using some local variables with the same names as the object properties ending up with something redundant like this:&#x20;

```javascript
const firstName = 'Foo';
const lastName = 'BAR';
​
const user = {
    firstName: firstName,
    lastName: lastName,
    email: 'foo.bar@wishtack.com'
};
```

... but thanks to the Object Literal Property Value Shorthand, it can be written in a shorter manner:

```javascript
const firstName = 'Foo';
const lastName = 'BAR';
​
const user = {
    firstName,
    lastName,
    email: 'foo.bar@wishtack.com'
};
```

{% hint style="info" %}
You should define your style guide concerning this syntax.

If the JavaScript ecosystem is quite new for the team, it is better to avoid this syntax which can be misleading.
{% endhint %}

{% hint style="warning" %}
Beware of IDEs that can't refactor Object Literal Property Value Shortands.

At Wishtack, we didn't use them until the refactoring was possible with IntelliJ / WebStorm.

{% endhint %}

![Refactoring with IntellJ](https://3339142615-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-LLu79csN7rNhazzx-Mu%2F-LLvFHG4ZV7TilW2mAv3%2F-LLvK1j384Ys5ahifddB%2Fintellij-shorthanded-properties.gif?alt=media\&token=e906f1b6-8a11-4105-bcb0-00bf16484ff0)

![Refactoring with VSCode](https://3339142615-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-LLu79csN7rNhazzx-Mu%2F-LLvFHG4ZV7TilW2mAv3%2F-LLvK_r3pyoWbAYAg0WM%2Fvscode-shorthanded-properties.gif?alt=media\&token=aee7b484-8d88-4b48-9652-ce309bf1287c)
