alert(3)
Just such a program, not written in function, I thought and thought, how to terminate js
alert(3)
return;
alert(3)
If you write it this way, if it fails, return can only terminate the function
I can’t find a solution online. Ask your friends. One said it’s not possible, and the other told me to try die
alert(3)
die;
alert(3)
Wow, I admire it, it actually worked
alert(typeof die)
What’s going on: undefined, undefined, the console reported an error
alert(3)
jfslk;
alert(3)
Ah, so it turns out, this jfslk can also achieve the same effect (terminating the js program)
It turns out, it turns out, it turns out that errors can be used to terminate js programs. It’s very useful! Has anyone used it this way? !