why does '\\\[' equals '\\[' ? How does backslash work in string?
As the title
console.log('\\\[' === '\\[');
A backslash before most characters will only be parsed as an unnecessary escape character - the backslash will be ignored. This is what's happening in the second part of the first string. Before a certain few characters though, such as another backslash in
\n, it will be parsed as a escape sequence.
\\ is the escape sequence for a single literal backslash:
Why does coronavirus kill some people and spare others?, Scientists are exploring genetic factors, including a person's blood type, how the virus is transmitted, and whether particular strains might be Does it take you forever to make a doctor’s appointment, clean out your garage, or do your taxes? Putting off something that needs to be done is called procrastination.We all do it sometimes.
In strings, the backslash (
\) is a special character used to encode other special characters, including the backslash.
\\) and an open square bracket (
[). In the compiled program the string is
\\) followed by the combination of characters
\[ that looks like an escape sequence but doesn't mean anything. Because this combination is not defined and
The behaviour is documented:
For characters not listed in the table, a preceding backslash is ignored, but this usage is deprecated and should be avoided.
Why does sex hurt?, Pain during or after sex (dyspareunia) can be caused by many things such as illness, infection, a physical problem or a psychological problem. The debate over reopening the economy has a peculiar characteristic: It breaks down almost entirely along political lines. Liberals emphasize the dangers of an open society, shaming those who want
Backslash is a special character. Literally, JS talk to browser to interpret the symbol after
\ as is. Sometimes it calls screening or shielding.
That is why we can write smth like that:
console.log("Double \"quotes\" inside another one."); with the result of
Double "quotes" inside another one. without any error. Although that is not the way we need to use anywhere.
"\\\["separates into 2 parts:
\[. First returns
\and the second returns
[. Finally it is
"\\["separates into 2 parts:
[. First returns
\and the second returns
[. Finally it is
No. 424: Why Does? Why Is?, Why Do Clocks run Clockwise? asks the title of a book by David Feldman. Why indeed! This odd book looks at 239 such questions. First they look innocent Answers to why you get goosebumps, hiccups, eye twitches, ringing in your ears, and the feeling of the hair on your neck standing up. Share on Facebook: http
Coronavirus (COVID-19) frequently asked questions, Can you contract the coronavirus disease from a package in the mail? Why do you press harder on a remote-control when you know the battery is dead? Why is it that in the US: If you take off all your clothes and walk down the street waving a machete and firing an Uzi, terrified citizens will phone the police and report: "There's a naked person outside!"
Coronavirus disease 2019 (COVID-19), Coronaviruses are thought to be spread most often by respiratory droplets. Although the virus can survive for a short period on some surfaces, it is unlikely to be spread from domestic or international mail, products or packaging. But how and why does it feel so good to have sex? Scientists know that sex is a pleasurable experience for most women. They say there’s a lot going on in the body that makes sex feel good.
Coronavirus disease (COVID-19) advice for the public: Myth busters, Although for most people COVID-19 causes only mild illness, it can make some people very ill. More rarely, the disease can be fatal. Older people, and those with pre- existing medical conditions (such as high blood pressure, heart problems or diabetes) appear to be more vulnerable. Why Does a Herniated Disk Happen & Will It Go Away? Anybody who has ever experienced a herniated disk before knows how painful it can be. A spine surgeon explains what’s actually happening and
[doesn't need to be escaped, i.e.
'\[' === '['