JavaScript Knowledge Point Notes

Source: Internet
Author: User

1  for (var i = 0; i < i++) {2     setTimeout (function() {3     Console.log (i);  // output 10 10, because the SetTimeout method is asynchronous, when executed to settimeout, the For loop has been executed, the I variable value is ten 4     }, (+); 5 }

1  for(vari = 0; I < 10; i++) {2(function(a) {3     //the value of the variable i is copied to a when passed to this scope,4     //so this value doesn't change with external variables.5SetTimeout (function() {6Console.log (a);//Output 0 1 2 3 4 5 6 7 8 97}, 1000);8}) (i);//here we pass in parameters to "closure" variables9}

1 //a declarative function definition statement is a top-level scope, and a function call statement can be written before a function declaration statement:2Add (1, 2);//33 functionAdd (m, n) {4Alert (m +n);5 }6 7 8 //functions defined by function expressions cannot be called until they are defined:9 //Typeerror:add is not a functionTenAdd (1, 2); one varAdd =function(m, N) { aAlert (m +n); -};

JavaScript Knowledge Point Notes

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.