Home > Web Front-end > JS Tutorial > body text

Summary of javascript script debugging methods_javascript skills

WBOY
Release: 2016-05-16 18:58:22
Original
965 people have browsed it
1. alert method
This is also a very primitive method, but it is very troublesome to debug.
2. Debugger method
First open Internet Options - Advanced, and uncheck "Disable script debugging (Internet Explorer)"
If you want to enable debugging in other browsers, you can change " Also uncheck "Disable script debugging (other)".
Then add debugger where you want to debug, such as


Open the page with IE, and VS2005 will be automatically called for debugging.
Click Yes, as usual Press F10 or F11 to debug

Anyone who is currently or preparing to engage in javascript programming will use this magical thing and feel extremely proud.
It can achieve almost any function you want without using any tools.
Then, anyone who has used it will know that this kind of programming script is quite troublesome when it comes to query errors or it is called debugging.

Below, I combine some of my own experiences, and of course some of them come from the Internet. Haha
1. Use the alert function

This function is most used during debugging. For a certain variable or array, if you think there may be a problem there, just there Local alert output, haha.
2. Use the syntax highlighting function of the editor

For some spellings, there may be errors. It is a good way to use an editor with syntax highlighting function. Currently, there is a grammar There are many editors with highlighting functions, such as editplus, UltraEdit, Dreamweaver, etc. If there are spelling errors of keywords (perhaps accurate reserved words) when writing code, they will be given in different colors.
document.write("hello World!");
If there is a spelling error in the reserved word in the previous sentence, the color will give a prompt,
documents.write("hello World!"); 3. Pay attention to the difference in size
(Note that html is not case-sensitive, but if your js code is written directly in html, it will seem to be different in size. You must pay attention to this)
This kind of scripting language is strictly case-sensitive. If you spell it wrong, not only will the color be wrong, but it will also cause a method error and you will not be able to continue execution.
4. Pairing of brackets

The brackets here include commonly used braces and brackets, which is an important point when checking.
5. Strictly implement the code indentation style

This is also very important, especially when querying errors. Of course, you can’t maintain this style just because of this. You are very good at it. Save time.
6. Use the browser to run and debug

In fact, every browser has a display function for errors, such as IE series, FF, etc., but you just haven’t noticed it. Let’s focus on it here. The debugging function of FF is particularly easy to use.
FF itself has an error console function. After it is turned on, it will prompt error messages. Of course, the most useful ones are Web Developer and FireBug plug-ins. There are many articles on how to use these two plug-ins.
Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template