Home >Web Front-end >JS Tutorial >How to check for unknown JavaScript errors

How to check for unknown JavaScript errors

藏色散人
藏色散人Original
2021-06-30 10:28:163470browse

How to find unknown javascript errors: first run the javascript page; then click the browser's settings icon and find "Developer Tools" in "More Tools"; finally open the tool and refresh the page. You see error messages on the console.

How to check for unknown JavaScript errors

The operating environment of this article: windows7 system, Google87.0&&javascript1.8.5 version, Dell G3 computer.

How to check for unknown JavaScript errors?

Write a test code first. The script is very simple. It just displays the results of a and b on the page.

How to check for unknown JavaScript errors

Run the page, and you can see that the correct results are output on the page.

How to check for unknown JavaScript errors

But if we make a mistake, write the code of a b in a bb, as shown in the figure

How to check for unknown JavaScript errors

Run page , the page does not display correct data, but no error is reported, and it does not affect the operation of the page.

How to check for unknown JavaScript errors

#In order to find this potential error, we can use the browser's developer tools.

Click the browser's settings icon, and then find 'Developer Tools' (Chrome browser) in 'More Tools'

(Press the shortcut key F12 or other shortcut keys, different browsing The shortcut keys are different for different systems)

How to check for unknown JavaScript errors

After opening the tool, refresh the page, and you can see a red error on the console, which prompts us that the variable bb is not defined. .

How to check for unknown JavaScript errors

You can also click to activate this button in the debugging page (source), which will enter the interrupt when an exception is encountered.

How to check for unknown JavaScript errors

After activation, refresh the page, you can see that the interruption is immediately entered, which makes it easier for us to find what went wrong.

How to check for unknown JavaScript errors

[Related recommendations: javascript advanced tutorial]

The above is the detailed content of How to check for unknown JavaScript errors. For more information, please follow other related articles on the PHP Chinese website!

Statement:
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