JavaScript redirect in if statement that prevents code execution without yielding errors
<p>Can I do a JavaScript redirect in an if statement that prevents code execution past that if, without having to throw or generate errors, nor putting the undesired code in an else block?</p>

<p><strong>Example of desired outcome that yields an error before redirect</strong></p>

<pre><code>if (true) {
  window.location.href = window.location.toString();
  throw "";  // Yields error, but stops execution. return; also yields error.
}
alert("Undesired code has been executed");
</code></pre>
