Home >Web Front-end >JS Tutorial >How to terminate the program in js and return cannot be replaced with jfslk_javascript tips

How to terminate the program in js and return cannot be replaced with jfslk_javascript tips

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOriginal
2016-05-16 17:33:001339browse

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? !

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn