Common Methods for console objects

Source: Internet
Author: User

Console. Log (): The most common method for debugging. It is used to display information in the console window.

console.log(123);  //123

 

Console. Warn (): when outputting information, add a Yellow Triangle at the beginning to indicate a warning.

Console. Warn ('output warning information'); // output warning information

 

Console. Error (): when outputting information, add a Red Cross at the beginning to indicate an error.

Console. Error ('output error information'); // output error message

 

Console. Assert (): used to verify whether a condition is true. If it is false, an error message specified in advance is displayed.

Console. Assert (true = false, 'judgment condition is not true '); // The Judgment condition is not true.

 

Console. Time () and console. timeend (): used to calculate the exact time spent on an operation

//time: 0.06msconsole.time(‘time‘);for (var i = 0; i > 100000000; i++){}console.timeEnd(‘time‘)

 

Console. dirxml (): used to display the code structure of web page elements

// Display the code structure of the current element var odiv = Document. getelementbyid ('one'); console. dirxml (odiv)

 

Console. Group () and console. groupend (): these two methods are used to group the displayed information. It is useful only when a large amount of information is output. It is divided into a group of information and can be folded/expanded with the mouse.

Console. group ('group 1') console. log ('group 1 Information 01'); console. log ('group 1 Information 02'); console. groupend ('group 1') console. group ('group 2') console. log ('group 2 Information 01'); console. log ('group 2 Information 02'); console. groupend ('group 2 ')

 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.