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:
Copy const firstName = ' Foo ' ;
const lastName = ' BAR ' ;
const user = {
firstName : firstName ,
lastName : lastName ,
email : ' [email protected] '
}; ... but thanks to the Object Literal Property Value Shorthand, it can be written in a shorter manner:
Copy const firstName = ' Foo ' ;
const lastName = ' BAR ' ;
const user = {
firstName ,
lastName ,
email : ' [email protected] '
}; circle-exclamation
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.