JavaScript template literal as object property name
This will throw an error in every JavaScript engine:
Code language: JavaScript
{
`mouseenter.${eventNamespace}`: handler,
}
Why? Because template literals are not actually literals, as confusing as that name is - they’re expressions. However, it is possible to (ab)use JavaScript’s zany, vibes-based type coercion to make this valid by wrapping the template literal in an array like so:
Code language: JavaScript
{
[`mouseenter.${eventNamespace}`]: handler,
}
This causes the JavaScript engine to evaluate the template literal into a string, then it coerces the array containing that one string into a string, which is then valid as the property name.