DEV Community

Discussion on: Make Your Code Cleaner, Shorter and Easier to Read! ES6 Tips and Tricks.

dshepsis profile image

The code sample for Dynamic Property Names is incorrect:

let  city= 'sheffield_';
let a = {
    [ city + 'population' ] = 350000
a[ city + 'county' ] = 'South Yorkshire';
console.log(a); // {sheffield_population: 350000, sheffield_county: 'South Yorkshire' }

On line 3, you use an = symbol instead of the : operator.

samwsoftware profile image
Sam Williams Author

Thanks for pointing that out. All changed now