tag function
Last updated
Was this helpful?
Last updated
Was this helpful?
Was this helpful?
tag function's first argument has a special raw
property, allows you to access the raw strings as entered, without processing escape sequences.
// ⭐️ tag function (template function)
function raw(strings) {
// ⭐️ first argument (`strings`) has a special `raw` property
return strings.raw;
}
// ⭐️ tagged templates
raw`line 1 \n line 2`, // [ 'line 1 \\n line 2' ] (`\n` not escaped)
raw`5 = \n ${2