JavaScript specifies the breakpoint operation instance tutorial

Although there are many unclear debugging tutorials, but still did not find which article written by the articles, and the sure yourself try to write their own Some use habits or experiences, I hope that children who are not very understanding to use breakpoints have some help

This article will give you more details on JavaScript to specify the relevant content of the breakpoint operation, share it out for everyone. Refer to the study, let’s take a look at it, let’s take a look at the detailed introduction

What is breakpoint action

Do the small end development Partners, perhaps this breakpoint is not very familiar. However, if you ask other languages ​​(such as C, C, C, C ++, C #, etc.), they should be very familiar with breakpoint operation, which is provided in IDEs such as Xcode or Visual Studio.

The following words comes from Zhizhi

The meaning of the breakpoint operation is to set the trackpoint. The tracking point is equivalent to a temporary breakpoint that prints the message to the Output window.

BreakPoint Action

JavaScript指定断点操作实例教程
Check the continuation execution of the following, when the TRACEPOINT hits Debugger will not stop, otherwise it will stop here. In both cases, the message will be printed.

JavaScript said: I need breakpoints


Imagine a scenario, I hope that when the program is running, you can observe someone on a certain line. Variables or expressions of the expression. You will say that this is not very simple:

Place Debug in the specified locationThe ger statement, or this hit a breakpoint here, then use console or variable listening to observe the value of the variable.

Dynamically inserts Console.log code.

It seems that the second way is a better way. Dynamic insertion code can of course use Chrome’s Live Edit function. At that time, we would like to have a way that does not directly modify the code. At this point you may think, then set a breakpoint to operate.

    JavaScript how to set breakpoint operation
  • The front-end children’s shoes must know that most of JavaScript debugging is operated in the browser, and this browser, Most of the time is Chrome. Because Chrome’s debugging is powerful and convenient. (I believe you will not be opposed.).
  • However, let everyone disappoint, Chrome does not set the function of breakpoint, and there is no other browser in the natural browser. I believe that your mood at this time is like this:

Didn’t tell you XX.

Don’t worry about it, and listen to us slowly. When the Chrome breakpoint is commissioned, the conditional breakpoint can be used, so-called condition breakpoint, specify a condition, when conforming to this condition. The execution will stop at the breakpoint, otherwise it will be executed directly down. As shown below, click Right-click on Line Number, select Add ConditionNal Breakpoint


, then input conditions, such as params.value == ‘value’ Such conditions, as shown below:

Breakpoint condition

For the condition breakpoint description, if you are still not very familiar, You can refer to relevant information more. JavaScript指定断点操作实例教程
However, what is the relationship between this breakpoint? To know, JavaScript is a dynamic language. Conditional judgment is actually available for any codeSegment. For example, the following code:

IF (express)

JavaScript指定断点操作实例教程

even EXPRESS is not a BOOL value or BOOL value Expressions or functions returned to BOOL are possible. This facilitates our operation.

JavaScript said: I am the most wit.


Unexpected JavaScript

Therefore, in the conditional input box of the condition breakpoint, we can enter the breakpoint operation we want to perform. Yes, such as Console.log. As shown
   
will eventually print out the value you want to view at the console, as shown:

Print Results

Since the console.log return value is undefined (final converted to false), the code will not be stopped here, but will be directly Under the implementation, this is equivalent to explaining the continuation of the concept of breakpoint operation. If you need to stop here, you can set the following expression: JavaScript指定断点操作实例教程

Breakpoint operation interruption execution

Conclusion

JavaScript指定断点操作实例教程 The design of the conditional breakpoint is not designed for this purpose. So this is a HACK, not a standard mode, not the original design. However, isn’t it a lot of WEB development? It is convenient to use it.

In this way, it is equivalent to adding the code snippet we want to perform without modifying the code.

Many students like to use console.log directly in the project so that when they are actually released, they will eventually delete these console.log code, and increase the workload. In this way, perhaps it can be reducedCONSLE.log in the product code.

Use this way, it is also possible to dynamically change the value of some variables. We know that some bugs can only be recovering in some specific values, which may be the server push, and the value of debugging at this time may depend on the value of the rear end. In fact, in this way, in this way, in this way, it can be enforced certain values, making the bug resent without relying on the value of the background.

JavaScript指定断点操作实例教程
Modify variable

Reference

JavaScript指定断点操作实例教程
https: // www. JB51.Net/Article/147623.htm

https://www.visualterialmicro.com/page/User-Guide.aspx?doc=working-with-breakpoints-when-hit.html

The above is the full content of this article. I hope this paper has a certain reference value for everyone’s learning or work. If you have any questions, please Message exchange, thank you for your support of Tumi Cloud.

© Copyright Notice
THE END
Just support it if you like
like0
share
comment Grab the couch

Please log in to comment