JavaScript - Template literals

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, confusingly. 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,
}