Js console output method (detailed description)

Source: Internet
Author: User
Js console output method (detailed description) console. log (object [, object,...])

Output a message on the console. If multiple parameters exist, the output parameters are separated by spaces.

The first parameter can be a string that contains the formatted placeholder output, for example:

Console. log ("The % s jumped over % d tall buildings", animal, count );

The above example can be replaced with the following code without formatting placeholder output:

Console. log ("The", animal, "jumped over", count, "tall buildings ");

In addition, these two methods can be used in combination. If a placeholder is formatted and the number of parameters provided is greater than the number of placeholders, redundant parameters are appended to the string by space separation, like:

Console. log ("I am % s and I have:", myName, thing1, thing2, thing3 );

If the parameter is a Javascript object, the output on the console is not a static text, but an interactive hyperlink. Click the hyperlink to view the HTML, CSS, Script, and DOM windows of the object, you can use the formatted string % o to replace Javascript objects.

Console. log ("Body tag is % o", document. body );

Format the string list:

Create a timer named name, call console. timeEnd (name) to stop the timer, and output the consumed time (milliseconds ).

Console. timeEnd (nam)

Related Article

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.