An analysis of the problem of the direct quantity of a function in Javascript-mozilla and IE _javascript skills
Source: Internet
Author: User
I write this here is also a point in doing JS when the problem encountered, when a note. Did not expect to be Hax "batch" of a meal, but also said that there is some truth. After all, this content is also perfunctory
In general, we use the direct amount of the function in JS to name a simple function.
<script type= "Text/javascript" >
var func=function (s) {Window.alert (s)};
Func ("Never-online")
</script>
This is also legal in IE or Mozilla (the ECMA Standard has a definition of the direct quantity of the function).
But there is another simpler way of naming in IE to simplify our code:
And this does not report syntax errors in Mozilla, but throws an exception that operators are illegal:
The following code captures the exception thrown by Mozilla and prints it out
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.