Computed (CP01)
1: const propertyName = "dynamicName";
2: const myObject = {
3: [propertyName]: "Dynamic Value" // propertyName evaluates to "dynamicName"
4: };
5:
6: console.log(myObject.dynamicName); // Output: "Dynamic Value"
Basic Usage Computed property names in JavaScript allow you to dynamically determine the name of a property during object creation. Dynamic Value
Computed context:
ES6 context:
Comments (
)
)
Link to this page:
http://www.vb-net.com/JavascriptES6/CP01.htm
|
|