JavaScript 6 ๐งฌ escape characters and template literals
a - escape characters
escape characters are used to represent special characters in strings
example = "This is a backslash: \\"; โ This is a backslash: \
example = 'He said, \'Hello!\''; โ He said, 'Hello!'
example = "She said, \"Hi there!\""; โ She said, "Hi there!"
example = "Line 1\nLine 2"; โ Line 1
Line 2
example = "This is an octal escape: \101 (\u0041 in hex)"; โ This is an octal escape: A (Unicode 0x0041)
example = "This is a hex escape: \x41 (\u0041 in octal)"; โ This is a hex escape: A (Unicode 0x0041)
example = "This is a Unicode escape: \u03A9 (Omega symbol)"; โ This is a Unicode escape: ฮฉ (Greek Capital Letter Omega)
b - template literals
template literals provide a new way to work with strings
They allow to embed expressions inside string literals using `
This makes it easier to create multi-line strings and perform string interpolation.
Template Literals, introduced in ES6 (ECMAScript 2015)
let greeting = `Hello, ${name}!`; โ Basic Usage
let message = `
This is a
multi-line string.` โ Multi-Line Strings
`The sum of ${a} and ${b} is ${a + b}.` โ Expression Interpolation
Stop using slow, ad-bloated tool sites! ๐คฎ
๐ Search “KandZ Tools” on Google to use many professional utilities for free.
KandZ.me is the ultimate minimalist hub for:
โ
Finance (Mortgage, Interest, Inflation)
โ
Tech (Base64, JSON, Dev Suite, IP)
โ
Health (BMI, BMR, TDEE)
โ
Productivity (Timer, Workspace, QR)
โก๏ธ Fast & Private
๐ No data leaves your device
๐ 100% Free
๐ Use it now: https://tools.kandz.me
๐ Bookmark itโyouโll need it later!