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

How to output JavaScript to the console

青灯夜游
Release: 2023-01-06 11:18:07
Original
11331 people have browsed it

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)
Copy after login
info()console.log alias, output information
console.info("php中文网")
Copy after login
log()Output information
console.log("php中文网")
Copy after login
warn()Output warning information
console.warn("警告")
Copy after login

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!

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
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!