Learn Basic JavaScript: Escape Sequences in Strings

Hi. In the page https://www.freecodecamp.org/learn/javascript-algorithms-and-data-structures/basic-javascript/escape-sequences-in-strings you give the ‘output’ of \b as ‘word boundary’. Shouldn’t this be ‘backspace’? It is only word boundary when used in a RegEx I believe. Correct me if I am wrong. Thanks.

Welcome, rcfroggatt.

I cannot think of how you could quantify a backspace. So, needing to escape one is difficult to understand.

I did find this on w3schools:

Six other escape sequences are valid in JavaScript:

Code Result
\b Backspace
\f Form Feed
\n New Line
\r Carriage Return
\t Horizontal Tabulator
\v Vertical Tabulator

The 6 escape characters above were originally designed to control typewriters, teletypes, and fax machines. They do not make any sense in HTML.


So, I do not think the idea of \b pertaining to escaping a backspace works, even outside of Regex.

Let us see if someone else has more knowledge on the topic :smiley:

To build further on this, trying to use the \b character in the editor does not produce a backspace, but rather generates a placeholder symbol.

image

1 Like

Thanks for your comments. Javascript: The Definitive Reference, 7th Edition, on page 34, also defines \b as backspace escape character. It seems more consistent to go with the standard Unicode definitions IMHO. Not every character has to be printable, right? E.g. \0 null character. And you can escape any other non-printing character using \u.

Most escape sequences are characters which either cannot be printed or not found in keyboard directly. That backspace doesn’t appear on editor is immaterial. The ES standards define \b as backspace as does every major language I know. See table 34 of ECMAScript 2015 Language Specification – ECMA-262 6th Edition

Is there a way to file bug report for tutorials here?

Thank you for helping make FCC better. Bugs can be reported as GitHub Issues. Whenever reporting a bug, please check first that there isn’t already an issue for it and provide as much detail as possible.