Understanding the escape sequences in javascript

-1

I have trouble understanding the usefulness of escape sequences.

To introduce some special characters inside a string of characters that can not be represented by text, we use what are commonly called escape sequences.

source: link

I want some examples to see the usefulness of them in javascript or more information about this topic.

    
asked by javier 09.11.2018 в 23:07
source

1 answer

0

The escape sequence is (simply) a support tool to represent those characters that sometimes we can not enter directly with the keyboard, either by physical or logical constraints. Example an emoji or line break:

let emoji = '\u{1F60D}';
let saltoLinea = '¡Hola\nmundo!';
let textoConComilla = 'Comilla simple (\'), comilla doble (").';

The language takes to recognize an escape sequence, translates what the code entails, being useful for both the programmer and the user.

I recommend the following reading: Strings - javascript.info .

    
answered by 09.11.2018 в 23:16