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

What are the methods of the javascript console Console object?

青灯夜游
Release: 2023-01-07 11:41:16
Original
1776 people have browsed it

js console methods include: assert(), clear(), count(), error(), group(), groupEnd(), info(), log(), table(), time( ), timeEnd(), trace(), warn(), etc.

What are the methods of the javascript console Console object?

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

javascript console Console object

The Console object is used for JavaScript debugging.

There is no Console object in native JavaScript by default. This is a built-in object provided by the host object (that is, the browser). Used to access the debugging console, the effect may be different in different browsers.

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.

Console object methods

##MethodDescriptionassert()The assert method accepts two parameters, the first parameter is an expression, and the second parameter is a string. The second parameter will be output only if the first parameter is false, otherwise there will be no result. clear()Clear all output of the current console and return the cursor to the first line. count() is used to count and output how many times it has been called. 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. group() is used to group the displayed information, and the information can be folded and expanded. groupCollapsed() is very similar to the console.group method. The only difference is that the content of the group is collapsed when it is first displayed. ), rather than expanded. groupEnd()End inline groupinginfo()console.log alias , Output informationlog()Output informationtable()Convert the composite type The data is converted into a table display. time()Time startstimeEnd()Time endstrace()Trace the calling process of the functionwarn()Output warning message

Commonly used Console debugging commands

console.log('hello');
console.info('信息');
console.error('错误');
console.warn('警告');
Copy after login

What are the methods of the javascript console Console object?

[Related recommendations:

javascript learning tutorial

The above is the detailed content of What are the methods of the javascript console Console object?. 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!