Skip to content
Advertisement

Tag: tagged-templates

Are TemplateObject arrays for tagged template literals weakly referenced by their realm?

The JavaScript runtime creates a frozen array like Object.freeze([‘str0 ‘, ‘ str1’]) but with an additional .raw property. Is it okay to use that object as a key in a WeakMap to avoid having to redo work based on the array each time through the loop? Section 12.2.9.3 Runtime Semantics: GetTemplateObject ( templateLiteral ) describes how this value is cached:

Advertisement