JavaScript debugging debug

First, the error

  1, a syntax error

    Error, prompted, it is easy to solve.

  2, logic errors

    Not easy to find

Second, the debug mode

  1, alert () mode

  2, console.log () / console.error () mode

  3, breakpoint debugging

    Breakpoint debugging refers to himself in a row setup a breakpoint, the debugger, the program will stop running to the line, then you can down step by step debugging, the debugging process can see the current values ​​of individual variables, error then the error debugging to the line of code that is an error, stop.

   Commissioning steps:

Browser, press F12 -> sources -> find the file needed to debug -> Set a breakpoint in a row the program

    Figure:  

 

    

  4, debugging related operations

    • Watch: monitoring, it can be monitored by changes in the value of the variable Watch, very common.
    •  F10: single-step program execution, allowing the implementation of the program line by line, this time to observe the changes in the value of the watch variables.
    •  F8: skip to the next breakpoint, if there is no break back, and the end of program execution.

           

    Tips:  watch variables, do not watch expressions, because monitoring the expression, the expression will be executed

 

 

Guess you like

Origin www.cnblogs.com/niujifei/p/11334075.html