← Lesson
BitWithBite
JavaScript · Quick Reference

Lesson 3 — Strings & Template Literals Cheat Sheet

JavaScript
In one line: In JavaScript, you can create strings using three types of quotes. Each has its use case, but backtick strings (template literals) are the most powerful and flexible — use them ...

Key Ideas

1Creating Strings. In JavaScript, you can create strings using three types of quotes. Each has its use case, but backtick strings (template literals) are the most powerful and flexible —...
2String Length. Every string has a .length property that tells you how many characters it contains — including spaces, punctuation, and symbols.
3Accessing Characters (Indexing). Strings are zero-indexed — the first character is at position 0, not 1. You can access individual characters using bracket notation or string methods.
4Essential String Methods. JavaScript strings have 40+ built-in methods. Here are the ones you'll reach for every day. Call them with dot notation: string.method().
5Template Literals (Backticks). Template literals are JavaScript's supercharged strings. They use backtick characters (`) and let you embed any expression directly inside using ${expression}. They al...

Code Examples

let name1 = 'Alice'; // single quotes let name2 = "Bob"; // double quotes let greeting = `Hello!`; // backtick (template literal) // Strings with special characters let msg1 = "She said \"hello\""; // escaped double quotes let msg2 = 'It...
let str = "Hello, World!"; console.log(str.length); // 13 console.log("JavaScript".length); // 10 console.log("".length); // 0 — empty string console.log(" ".length); // 2 — spaces count! // Real-world: validate minimum input le...
let lang = "JavaScript"; // J a v a S c r i p t // 0 1 2 3 4 5 6 7 8 9 // Bracket notation (most common) console.log(lang[0]); // "J" — first character console.log(lang[4]); // "S" console.log(lang[9]); // "t" ...