First sentence: var str = "My name is'" name "'"
Second sentence: var str = "My name is\"" name "\""
You said that only double quotes can be nested within single quotes, and only single quotes can be nested within double quotes. I can understand the first sentence, but I can't understand the second sentence because it is full of double quotes.
\ is an escape character, and the symbols following it become entity output, and there are no quotation marks here.
"My name is\"", in fact, I want to output: My name is"
and then connect the name,
"\"", this output is",
The final output is: My name is "name",
\ is the escape character, if there is no \ in "\"", the syntax is wrong, and with \, has become escaped, you can output the "
immediately following \\ This is called an escape character, which means that the symbol behind it is directly output