View JavaScript pre-loading from function Definition

Source: Internet
Author: User
JavaScript compilation only checks whether there is any code error and does not run the code. You can try

Defining a function in JavaScript can be written in two ways:

Function ftn () {}// first var ftn = function () {}// second

Some people say that these two methods are completely equivalent. However, before parsing, the previous write method will be automatically promoted to the Code header by the parser, which violates the principle defined and used by the function. Therefore, when defining a function, we recommend that you, all adopt the latter method.

After reading this sentence, I first felt that the two statements were completely consistent during use, but they were resolved differently. However, his explanation "the previous writing method will be automatically promoted to the Code header by the parser" left me confused.

If I have the following first test:

Related Article

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.