From adb50fe16a6745ed60751c26b83636eb63387870 Mon Sep 17 00:00:00 2001 From: Ibrahim Abdulhameed Date: Sat, 30 Aug 2025 18:10:29 +0100 Subject: [PATCH] feat: add backtics to JS strings --- source/_posts/javascript.md | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/source/_posts/javascript.md b/source/_posts/javascript.md index 66920ab..bc368fc 100644 --- a/source/_posts/javascript.md +++ b/source/_posts/javascript.md @@ -60,11 +60,17 @@ console.log(a); // => undefined ### Strings ```javascript -let single = 'Wheres my bandit hat?'; -let double = 'Wheres my bandit hat?'; +let singleQuotes = 'Wheres my bandit hat?'; +let doubleQuotes = 'Wheres my bandit hat?'; +// this is used to embed expressions or for creating multi-line strings +let backTicks = `Wheres my bandit hat? ${some_value}`; + +// they can also be mixed, +// NOTE: if you need the functionality of the backticks, use it as the surrounding quotes +let mixedQuotes = `hello ${'dear' + name}, "let's have a great day today`; // => 21 -console.log(single.length); +console.log(singleQuotes.length); ``` ### Arithmetic Operators