📄Escape Character
Also known as Escape Sequence, Backslash Escape, Escaping
A mark that changes what the next letter means. Most often it is a backslash.
Think of it like
Think of it like a secret signal to a friend. It says the next word does not mean what it looks like.
Example
Jack writes a Windows path in his code as C:\\Users\\Jack. Each double backslash prints as a single one.
Why it matters
Escaping is how text can hold the characters that would break it. Getting it wrong causes many bugs and some attacks.
Definition
Example code
javascript
console.log("She said \"hi\"\nBye")
// She said "hi"
// ByeCommon mistake
Key takeaways
- 1Changes the next one. The character after it is special.
- 2Mostly a backslash. Most languages use the backslash.
- 3Hidden characters. A backslash and n make a new line.