Setting the property name into brackets give the ability to evaluate its value as an expression. Thus custom property names can be created:
let a = {
['foo' + 1]: i,
}
console.log(a.foo1) // print 1
javascript
programming
tips
FoldFold allExpandExpand allAre you sure you want to delete this link?Are you sure you want to delete this tag?
The personal, minimalist, super-fast, database free, bookmarking service by the Shaarli community