Object Initialization With Shorthand Property Names
If I have some variables:
and I'd like to initialize an object with them, I'll generally do something like the following:
That seems pretty standard, but with ES6 comes a feature called shorthand property names which makes that look verbose and redundant. If you already have properly named variables, they can be used as a short hand for both the key name and variable value:
See the MDN Docs for Object Initializer for more details.
Last updated