String in JavaScript

String Escape

🙋 Need help? Ask an expert now!

String escaping is act of replacing reserved characters with their escape sequence. Escaping is done by replacing the reserved characters with their escape sequences, which are all defined online for convenience. The most common case of using escape characters is when you work with client-side JavaScript that involves HTML and CSS. The reserved characters for client-side are <, >, &, ' and ".

The function above is a function that can be used with html. It converts the reserved characters in html to html entities using regular expression, a concept you will learn about later in the course. This is why you see strings like "\<" in the console when you run the program.

Edit Me on GitHub!

Application Question

Which of the following statement uses string escape correctly?