Get the App
SLTechnology News&Howtos  ›  Development  › 

How to implement breakpoints in JavaScript

Shulou Source: shulou.com Published: 2022-06-01 05:03:00 11月13日 Update

This article mainly shows you "how JavaScript achieves breakpoints". The content is simple and easy to understand. It is clearly organized. I hope it can help you solve your doubts. Let Xiaobian lead you to study and learn "how JavaScript achieves breakpoints".

breakpoint

To help us understand the functionality of code, JavaScript debugging tools (such as DevTools) can block script code execution by setting breakpoints, which are also the most basic in code debugging.

If you've studied debuggers or x86 architectures, you're probably familiar with the 0xCC directive. In JavaScript, we have a similar directive called debugger. When we declare the debugger function in our code, the script code stops at the debugger directive. For example:

console.log("Seeme! ");debugger;console.log("Seeme! ");

Many commercial products define an infinite loop debugger directive in their code, although some browsers block this code and some do not. The main purpose of this approach is to annoy people who want to debug your code, because an infinite loop means that the code keeps popping up asking if you want to continue running script code:

setTimeout(function(){while (true) {eval("debugger") The above is "JavaScript how to implement breakpoints" All the content of this article, thank you for reading! I believe that everyone has a certain understanding, hope to share the content to help everyone, if you still want to learn more knowledge, welcome to pay attention to the industry information channel!

Tags: Code breakpoints instructions content articles scripts help learning looping research running constantly products functions functions can be passed business that is tools meaning Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Shulou Tech Info vpn Shulou Technology macOS MySQL