I am trying to learn XSS from Portswigger, and in its lab https://portswigger.net/web-security/cross-site-scripting/contexts/lab-javascript-string-angle-brackets-double-quotes-encoded-single-quotes-escaped, my approach yielded the following javascript code.
<script>
var searchTerms = '\\';
alert(1);
\\'';
</script>
The problem is that this code shows me an error. But since Javascript is an interpreted language, shouldn't it first show the alert and then show the error?
<script>
var searchTerms = '\\';
alert(1);
whatever;
</script>
Like the code snippet above is wrong as well. Here also I get an error, but the alert is also shown. So why not in the first case?