JavaScript Learning Notes (function---learn again)

Source: Internet
Author: User

1. Definition of functions

2. Recursive invocation of functions

3. Closures

1. Functions are defined in two ways:

First type: function declaration

function functionname (arg0,arg1,arg2) {  //body  }

function declaration, an important feature is the function declaration promotion, that is, the function declaration is read before executing the code.

The second type: using function expressions

var functionname = function (arg0,arg1,arg2) {   //body      };

function expressions, like other expressions, must be assigned before they are used.

The difference between the two ways of creating a function declaration is that the function is declared in a way that causes the function declaration to be promoted.

2. Arguments.callee implementation of recursive calls to functions

Arguments.callee is a pointer to a function that is executing, so it can be used to implement recursive calls to functions.

Pros: When writing recursive call functions, using Arguments.callee is always more insured than using the function name.

3. Closures

Closure: Refers to a function that has access to a variable in another function scope.

A common way to create closures is to create another function inside a function.

JavaScript Learning Notes (function---learn again)

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.