Dynamic Object Keys
Dynamic Keys
π¨βπΌ We need to model error pages where the property name isn't a valid
identifier (like
status-404).When the property name is stored in a variable, you can use a computed property
name in an object literal:
const key = 'status-404'
const errorPages = {
[key]: '/not-found',
}
π¨ Open
and:
- Use computed property names in an object literal
- Set values alongside those computed keys