Differences
This shows you the differences between two versions of the page.
| programming:javascrip [2026/01/26 09:43] – created mh | programming:javascrip [2026/01/26 09:44] (current) – mh | ||
|---|---|---|---|
| Line 109: | Line 109: | ||
| ==== Common pitfalls to be aware of ==== | ==== Common pitfalls to be aware of ==== | ||
| - | Template literals use backticks, not quotes | + | Template literals use **backticks**, not **quotes** |
| - | ${} is not jQuery or shell syntax — it’s JS-only | + | '' |
| - | Don’t confuse ${} with $(...) (shell / jQuery) | + | Don’t confuse |
| - | You were correct to ask — many people mix those up. | + | ==== TL;DR ==== |
| - | TL;DR | + | * '' |
| + | * It replaces string concatenation cleanly | ||
| + | * It improves readability and formatter behavior | ||
| + | * It’s safe, modern, and efficient | ||
| + | * It’s the idiomatic way to build strings in modern JS | ||
| - | ${...} is expression interpolation inside template literals | ||
| - | |||
| - | It replaces string concatenation cleanly | ||
| - | |||
| - | It improves readability and formatter behavior | ||
| - | |||
| - | It’s safe, modern, and efficient | ||
| - | |||
| - | It’s the idiomatic way to build strings in modern JS | ||
| - | |||
| - | If you want next, we can: | ||
| - | |||
| - | define a logging helper so you never build these strings manually again, or | ||
| - | |||
| - | talk about when not to use template literals (there are a few edge cases). | ||