The string literal in this statement...
var result = parser.parse('"abc\"def"');
... actually doesn't contain a backslash. In JavaScript this sequence of symbols - \"
- is parsed as a single one - "
- no matter what quotation marks are used to delimit a string - double or single ones. JS doesn't interpolate variable and expressions in strings, and there is basically no difference between those.
This string - '"abc\\"def"'
- however, has a backslash: it's encoded by that \\
sequence. Note that it's not necessary to use another backslash to escape the double quote itself (as delimiters are single quotation marks). But you'd have to, if "\"abc\\\"def\""
form were used.