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 %>'] } } }
the
[]:[]
it works, I just have not used it or seen it before.
The square brackets themselves are not typed unless they are shown in bold. | A vertical bar that separates two or more elements indicates that any one of the elements can be typed. < > Bold angle brackets are part of the syntax, and must be typed unless indicated otherwise.
The [] operator converts the expression inside the square brackets to a string. For instance, if it is a numeric value, JavaScript converts it to a string and then uses that string as the property name, similar to the square bracket notation of objects to access their properties.
Use square brackets to include words within a quote that are not part of the original quote. For example, if a quoted passage is not entirely clear, words enclosed in square brackets can be added to clarify the meaning.
A method is a property that can be called (for example, if it has a reference to a Function instance as its value). There are two ways to access properties: dot notation and bracket notation.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With