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.
\为转义字符,它后面跟的符号变成实体输出,这里不再有引号的作用。
"我的名字叫做\"",其实就是想输出:我的名字叫做"
然后连上name,
"\"",这个输出的是",
最终输出的是:我的名字叫做"name“,
\是转义符,"\""中,如果没有\,语法错误,而有了\,就成了转义,可以将紧跟在\后的”输出
\ 这个叫转义符,意思就是它后面的一个符号直接输出