如何在某个点之后停止解释javascript?

ens*_*are 3 javascript jquery jquery-plugins dom-events

我的脚本的前几行看起来像:

if (window.location.hash) {
    window.location = window.location.hash.substring(1);
}
Run Code Online (Sandbox Code Playgroud)

如果此语句返回true,我希望"跳过"整个脚本.有没有办法做到这一点,除了把我的整个脚本放在一个巨大的if语句中?

谢谢.

Eti*_*rot 5

回来吧.

if (window.location.hash) {
    window.location = window.location.hash.substring(1);
    return;
}
Run Code Online (Sandbox Code Playgroud)

请注意,脚本仍将被解析直到结束,因此它必须始终是有效的JavaScript.但我认为你的意思是"解释"在标题中.