Create an object with dynamic property names [duplicate]

If you’re using ES6 (or something like Babel/browserify), you can write it like this:

iconMap : { 
    [KEYS.PHONE_TYPE] : 'icon-phone', 
    [KEYS.AGENT_TYPE] : 'icon-headphones'
};

Leave a Comment