JavaScript process control


(1) Branches

  1. If with else if, else
  2. Switch with case and default
    [difference] ① the comparison range of the former is written according to ‘bubble sort’, with more branches; ② The latter satisfies a specific value, has fewer branches and can be interrupted, and has higher execution efficiency. The value of ‘case’ is congruent

(2) Cycle

  1. For double for
  2. While contains do while, the former plays first and then cuts; The latter should be executed first and followed by the latter
    The former pays attention to count and number; ② The latter focuses on more complex and flexible conditions

(3) Attention

  1. If, switch, while (the expression is true), execute the statement; For needs to declare the counter loop body, meet the termination condition, and increase or decrease the variable
  2. The loop body can be embedded with branch statements to judge the flow
  3. Monitoring process can be debugged through breakpoint