Within strings, a \ is used to encode escape sequences. That is, it is used to encode things that would be difficult to put inside the string in some other way. For that we have \n that denotes a line break, the \t that denotes a tab, the sequences \u1234 to encode specific unicode characters and some other cases. All these cases are solved in compilation time (although javaScript is interpreted, it makes a compilation just-in-time before you start interpreting the code). Thus, in the string "Bom\ndia" what the compiler will mount will be a string with Bom, a line break and dia.However, since the character \ is used to make the escape of other sequences, so as it would be to put the character itself \ in the string? The answer is with the exhaust sequence \\. That's why inside strings when you want to write the character \, he has to be folded.Similar cases happen with the ' and with ", which by being string terminators, can be represented as \' and \", respectively when they are within the string.So far we do not talk about regular expressions, but the thing complicates because regular expressions also use the character \ to make escape, and uses it to make escape sequences that are largely different from those made with strings (although to make the escape of own \, regular expressions also use \\). So if you have a string that appears in the code as "\\d+", the compiler just-in-time JavaScript will mount in memory a string with content \d+ and then the regular expression compiler will compile this regular expression for an object that accepts one or more characters in the range '0' a '9'.The point (.) is a character that has nothing special in the strings, so it does not need to be represented by any escape sequence. However, in regular expressions, it has special meaning because it can represent any character. So, new RegExp("abc.def") will become a regular expression that recognizes 7 characters, the first three being abc, the last three def and the middle, anything.And how to then represent the character . in a regular expression literally? In this case, regular expression should be used \.. Only if this is coded as string, you will have to use "\\.".What happens is that when you represent regular expressions with strings, there are two build steps involved. One to mount the string in memory, applying the required escape sequences and a second to convert the string into a regular expression, also applying the required escape sequences. This means that in this case, the programmer has to keep an eye on what is being mounted when, what can be quite confusing considering that the two steps use the same character \ to represent escape sequences.However, when you use regular expressions delimited by /, as in /\d+/ or in /\./, in this case you are not building a string, but instructing the compiler to build the regular expression directly without the intermediate step of representing it as string. That is why in that case \d and \. should not be represented as \\d or \\..Oh, and that's why new RegExp("\\\\") is the regular expression that is used to recognize a single \ singular. The string that will be mounted will \\, interpreting as regular expression, becomes only \.