The original code is as follows: the returned result is returned, but an error is reported on the console, and the historical rollback cannot be performed. The error text is UncaughtSyntaxError: Illegalreturnstatement. What is the problem with the front-end experts, it seems that the href attribute of the link cannot be written as a return expression. Of course, you may not write it like this. You just want to know why an error occurs. Why cannot I write a return expression in href? Thank you! The original code is as follows: the returned result is returned, but an error is reported on the console, and the historical rollback cannot be performed. The error text is Uncaught SyntaxError: Illegal return statement. Could you tell me the front-end experts, what is the problem? It seems that the href attribute of the link cannot be written as a return expression. Of course, you can not write it like this. You just want to know why an error occurs. Why can't you write a return expression in href? Thank you! Reply content: both of the existing answers are incorrect... I had to come up and answer it... Are you sure you want to solve this problem...
You must be aware that the following two types of code look like this, but the actual working principle is completely different:
Class A (href ):
Href = "javascript: your_code_here"> A Link
Return is a keyword, not an expression. It must appear in the function. Big Brother. js. Try to answer this question. please correct me.
The cause of the error is:
When a "return" statement is executed in a non-function statement, it is considered invalid by js.