loading...

re: Make Your Code Cleaner, Shorter and Easier to Read! ES6 Tips and Tricks. VIEW POST

FULL DISCUSSION
 

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.

 

Thanks for pointing that out. All changed now

code of conduct - report abuse