Tagged Template Does MATH in Strings?!

Tagged templates can EXECUTE CODE! The tag function receives values and can transform them. This one DOUBLES every number. String interpolation becomes code execution!

#javascript #javascripttricks #taggedtemplates #templateliterals #stringinterpolation #javascriptweird #javascriptquiz #codingchallenge #javascriptshorts #javascriptwtf #templateprocessing #advancedjavascript

https://www.youtube.com/watch?v=9VcxL27MZGQ

Tagged Template Does MATH in Strings?! #javascripttricks

YouTube

Tagged Template Literals Have RAW Property?!

Template literals have a SECRET! The raw property shows escape sequences as LITERAL characters. \n becomes TWO characters, not one newline. This hidden feature will blow your mind!

#javascript #javascripttricks #templateliterals #taggedtemplates #rawproperty #javascriptweird #javascriptquiz #codingchallenge #javascriptshorts #javascriptwtf #stringescaping #advancedjavascript

https://www.youtube.com/watch?v=XDCGZxXAJR0

Tagged Template Literals Have RAW Property?! #rawproperty

YouTube

Tagged Template Does MATH in Strings?!

Tagged templates can EXECUTE CODE! The tag function receives values and can transform them. This one DOUBLES every number. String interpolation becomes code execution!

#javascript #javascripttricks #taggedtemplates #templateliterals #stringinterpolation #javascriptweird #javascriptquiz #codingchallenge #javascriptshorts #javascriptwtf #templateprocessing #advancedjavascript

https://www.youtube.com/watch?v=9VcxL27MZGQ

Random JavaScript idea—flags in tagged templates (*):

log`Entry ${{i:bigintId}}: ${{j:jsonObj}}`

(*) https://exploringjs.com/impatient-js/ch_template-literals.html#tagged-templates
#JavaScript #TaggedTemplates

Using template literals and tagged templates • JavaScript for impatient programmers (ES2022 edition)