JavaScript under function declaration some summary _javascript tips

Source: Internet
Author: User
function Test () {
return 123;
}


Apparently, it's a function statement, what's down there?
var b=function () {return 123};


This everyone doubts, as if not a declaration, because the function does not have a name, but an anonymous function, OK, look again
var b=function test () {return 123};


This is not a function statement, as if, then I answer you "no"
alert (test);
var b=function test () {return 123};


Can be in no IE above any JS implementation to test, will report test undefined error, if so
var b=function test () {return 123};
alert (b);
alert (test);


The function test () {...} is displayed. Such a function tostring result, can be a second alert or an exception, why, that is, the function test () {return 123} is not a declaration, but a function object, put the reference in B. So it's not like declaring a function object bound to the test name, so why don't I call the IE test, because
alert (test);
var b=function test () {return 123};


IE will show the function, IE is stupid, does not distinguish between individual function declarations and = the right of the functions of the object difference, in addition, ie even support function String.prototype.test () {...} Such a statement, see IE JS bug is really a lot of, no wonder Wilson does not support ES4, have to make a es3.1 out, in fact, is their own bug modified version

Contact Us

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.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.