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

前端 未结 1 1757
日久生厌
日久生厌 2020-11-22 12:38

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 %&g         


        
相关标签:
1条回答
  • 2020-11-22 13:07

    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.

    0 讨论(0)
提交回复
热议问题