1D0-635 · Question #37
Which special character in JavaScript is interpreted as a new line?
The correct answer is B. \n. See the full explanation below for the reasoning.
Question
Which special character in JavaScript is interpreted as a new line?
Options
- A\
- B\n
- C\b
- D\t
How the community answered
(23 responses)- A13% (3)
- B74% (17)
- C4% (1)
- D9% (2)
Community Discussion
8\n is the newline escape sequence in JavaScript (and most C-style languages), so B is your answer. \\ is a literal backslash, \b is backspace, and \t is a tab, none of which move you to a new line.
That is spot on, and worth adding that \n specifically moves the cursor to a new line without a carriage return, which matters if you ever pipe output to a Windows system expecting \r\n.
Yeah B is right, backslash n is the newline escape sequence in JavaScript, same as in most C-style languages. My senior had me use it inside a template string once to force a line break in a console log output and it worked exactly as expected.
Quick add here, the fun twist with template strings specifically is that you do not even need backslash n at all, since a real physical Enter key inside the backticks already counts as a newline, so think of it this way: backtick strings are "what you see is what you get," while regular quotes need the escape to spell out the invisible character.
The answer is B, backslash-n, which is the escape sequence for a newline character in JavaScript strings. Where I would push back on the question slightly is the phrase "special character," because what we are really talking about is an escape sequence, and that distinction matters when you get into how parsers and renderers actually handle whitespace. The tempting distractor here is D, backslash-t, because a lot of people conflate whitespace types and assume a tab counts as a "new line" since both affect layout visually, but a tab moves the cursor horizontally, not vertically. Backslash-b in option C is a backspace, which barely comes up in real web work but shows up on these exams specifically to catch people who are guessing from half-remembered memory. Know your escape sequences cold before test day, especially if you are going into any client-side scripting questions on the 1D0-635.
Froze on this one, remembered N for New line, marked B and passed.
The mnemonic works in a pinch, but make sure you also lock in that BR is void and self-closing, because the exam will sometimes test whether you know it takes no content or end tag, not just that it creates a line break.
\n is your newline, not \t (tab) or \b (backspace), B is it.