Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

What are the methods of JavaScript debugging

2025-01-18 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/01 Report--

This article mainly introduces the relevant knowledge of "what are the methods of JavaScript debugging". The editor shows you the operation process through an actual case. The operation method is simple, fast and practical. I hope this article "what are the methods of JavaScript debugging" can help you solve the problem.

For this problem, it is difficult for us to write JavaScript without a debugger, so we will have a lot of problems when writing code, syntax errors and logic errors are more difficult to diagnose. Generally speaking, nothing happens when we have a problem writing the code, and it doesn't give us the wrong message.

1. Console.log () method:

Let's take a look at the following code:

My first web page

Use F12 to activate debugging in browsers (Chrome, IE, Firefox), and then select console from the debugger menu.

A = 5 + b = 6 * c = a + b * console.log (c)

We still need browser support for this method, so we can use this method to check the value of JavaScript in our page. Generally, we can click F12 in the browser to open our controller for debugging.

2. Set breakpoints

We can set breakpoints in the JavaScript code in the debug window, and in each breakpoint, JavaScript stops execution, which makes it easy for us to query the value of JavaScript, and can resume the execution of our code after the query.

3. Debugger keywords

When using this method, we will stop the execution of JavaScript and call our debug function, which is the same as the function of setting breakpoints in our debugger. We can take a look at the following code:

After opening the debugger, the following code should stop execution before the third line is executed.

Var x = 15 * 5 * debuggerscape document.getElementById ("demo") [xss_clean] = x

When we are using this method, the above code stops running before the third line is executed.

4. Debugging tools for mainstream browsers

Chrome

Open the browser, select tools from the menu, select developer tools from tools, and finally, select the console.

Firefox Firebug

Internet Explorer

Open the browser, select the tool from the menu, select the developer tool from the tool, and finally, select the console.

Opera

Safari Develop Menu

Click the Safari menu, preferences, Advanced, and then select "Show error console" by selecting "enable development menu in the menu bar" and when the new option "development" appears in the menu.

This is the end of the content about "what are the methods of JavaScript debugging". Thank you for your reading. If you want to know more about the industry, you can follow the industry information channel. The editor will update different knowledge points for you every day.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report