JavaScript study notes-break and continue and test performance, garbage collection

One, break

  1. The break keyword can be used to exit a switch or loop statement, but cannot be used in an if statement.
  2. The break keyword will immediately terminate the loop statement closest to it.
  3. You can create a label for the loop statement to identify the current loop. label: Loop statement.
  4. When using the break statement, you can follow the break with a label, so that the break will end the specified loop instead of the nearest one. break loop name;

Two, continue

  1. The continue keyword can be used to skip the current loop.
  2. continue is also by default will only work on the loop closest to it.
  3. It is also possible to terminate the current cycle through a label
  4. Break is to terminate the entire loop, and continue is to terminate the current loop.

Three, test the performance of the following programs

Before the program is executed, turn on the counter

console.time("counter name") can be used to start a timer.
It requires a string as a parameter, and this string will serve as the identifier of the timer.
console.timeEnd() is used to terminate a timer
console.timeEnd("timer name")

Four, garbage collection GC

Too much garbage will cause the program to run too slowly. Need to create a garbage collection mechanism to deal with the garbage generated during the running of the program.
Set objects that are no longer used to null.

Guess you like

Origin blog.csdn.net/weixin_45636381/article/details/112739932