Home  >  Article  >  Web Front-end  >  How to output JavaScript to the console

How to output JavaScript to the console

青灯夜游
青灯夜游Original
2021-06-23 18:03:0511355browse

Output method: 1. Use the "console.log (information)" statement to output information; 2. Use the "console.info (information)" statement to output information; 3. Use "console.warn (warning)" The statement outputs warning information; 4. Use the "console.error(information)" statement.

How to output JavaScript to the console

The operating environment of this tutorial: windows7 system, javascript version 1.8.5, Dell G3 computer.

In JavaScript, you can use the methods of the Console object to output from the console.

Two common uses of the Console object:

  • Display error information when the web page code is running.

  • Provides a command line interface for interacting with web page code.

Method Description Instance
error( ) When outputting information, add a red cross at the front to indicate an error, and the stack where the error occurred will be displayed.
console.error("Error: %s (%i)", "Server is not responding",500)
info() console.log alias, output information
console.info("php中文网")
log() Output information
console.log("php中文网")
warn() Output warning information
console.warn("警告")

Taking the Chrome browser as an example, we can open the Console window by pressing F12 or Control Shift i (PC platform) / Alt Command i (Mac platform) .

How to output JavaScript to the console

[Related recommendations: javascript learning tutorial]

The above is the detailed content of How to output JavaScript to the console. 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