Computed Property Names in Javascript
Computed Property Names is an ES6 feature which allows the names of object properties in JavaScript object literal notation to be determined dynamically, i.e. computed. JavaScript objects are really dictionaries, so it was always possible to dynamically create a string and use it as a key with the syntax object[‘property’] = value. However, ES6 Computed Property Names allow us to use dynamically generated names within object literals. Example: const myPropertyName = 'c' const myObject = { a: 5, b: 10, [myPropertyName]: 15 } console....