What do square brackets around a property name in an object literal mean?

I've been writing in JS for a while and have not used this form:

  dist: {
    files: {
      [bpr + 'lib/Monster.min.js']: ['<%= concat.dist.dest %>']



it works, I just have not used it or seen it before.



Only recently with ES6. They are called "computed property names"

From MDN:

Starting with ECMAScript 2015, the object initializer syntax also supports computed property names. That allows you to put an expression in brackets [], that will be computed as the property name.


Recent Questions

Top Questions

Home Tags Terms of Service Privacy Policy DMCA Contact Us

©2020 All rights reserved.