Review Summary 1

Source: Internet
Author: User

Written questions

the difference betweenseajs and requirejs :requirejs is the implementation of the AMD specification, Therefore all dependent modularity is performed first (that is, pre-executed) and relies on the predecessor. (Requirejs support for CMD from 2.0 version )

Seajs is the execution of the CMD specification, so all dependent modularity is lazy execution (that is, deferred execution), dependent on the nearest.

Second, why to Modular: Embedded Web page js is more and more large and complex, in the development process usually requires teamwork and collaboration, developers have to use software engineering methods to manage the business logic of the Web page (processing data logic). Plug- in , easy to directly call someone else or your own well-written modules .

Three, Seajs and requirejs respectively How to expose the interface to use:seajs is through module.exports  to expose what is needed. Requirejs is to expose what is needed by return .

  1. Closures: Define a function, and a variable in the method. The closure is generated when execution does not release memory. Method is called, the method and the variable to be called are first found in the function, and if not, it is found along the scope chain. The closure cannot be freed and consumes memory.
  2. Variable elevation:JS will be an EC when executing a function ,theEC contains AO, So it would be good for Mister to make all the variables, but no assignment, just scanned the code again. Then execute the code. This is the increase of the variable.
  3. Js is single thread: Divided into queue event stack. The code for the queue event executes only after the code that executes the stack is executed. And the stack is advanced and out, the queue event is FIFO. Loop to execute. setimeout This belongs to the queue event.
  4. Setimeout: This is called by the Window object. Note The difference between this.
  5. Sort the array: Bubble algorithm, or use arr.sort() and arr.reverse().
  6. The lastvalue of I: The value ofI is the last value. The loop is executed once, so the i value has changed. Can only be the last value. and notice The boundary of the I value. Thought i was finally i++ added, so greater than the condition of the loop.

Machine questions:

/* First question * /

Application: Calculating factorial

Knowledge Point: for Loop

var res = 1;

for (var i = 1;i <= 9; i + = 2) {

Res *= i;

}

Console.info ("res =" + res);

/* second question * /

Application: Calculation of odd and even numbers and

Knowledge Point: for loop,if Else judgment

var odd = 0, even = 0;

for (var i = 0;i <=; ++i) {

if (i% 2)

even + = i;

Else

Odd + = i;

}

Console.info ("odd =" + Odd + ", even =" + even);

/* Third question * /

Application: Calculation

Knowledge Point: The judgment of the for loop if

var count = 0;

for (var i = 1; I <= 4; ++i) {

for (var j = 1;j <= 4; ++j) {

if (i! = j) {

for (var k = 1; k <= 4; ++k) {

if (i! = k &&J! = k) {

+ + count;

Console.info ("" +i + j + k);

}

}

}

}

}

Console.info ("Count =" + count);

/* question fourth * /

Application: Calculation of prime numbers and

Knowledge Point: for loop if judgment and loop bounce

Count = 0;

for (var i = 101; i <; ++i) {

for (j = 2,len = parseint (Math.sqrt (i) + 1); J <= Len; ++j) {

if (i% j = 0) {

Console.info ("i =" + i + ", j =" + J ");

+ + count;

Break

}

}

}

Console.info ("Count =" + count);

Review Summary 1

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.