Nodejs learning two in-depth understanding of console

Source: Internet
Author: User

In the previous article, we wrote the first program with Console.log, though it was so simple. So I'm going to tell you about the object in node. js.

For people who have studied Java. NET, the Word object should be very kind, and if you don't feel kindly, learn the object-oriented first.

In our programming, everything is the object. You can think of anything as an object.

However, there are objects in node. js, and console is an object. Since it is the object, he should have a public method. As you can see, log is the way it is, seemingly static.

So what are the methods in the console, let's let him output it.

Oh, the console still has so many hidden methods. The console object is mentioned below.

Console is a console object that is provided by node. JS, which contains the function error to standard output (stdout) log, which is output to standard error (STDERR).

Console.log () functions like printf () in other languages, it takes a string and automatically adds a newline character (\ n), and Console.info is its alias. Console.warn is the alias of Console.error.

Console.dir borrowed the Sys module's inspect () method to directly input the object's string representation into the standard output stream.

Console.assert generic debugger, throws a custom exception message if there is a wrong way.

Console.trace () enters the current call stack to the standard error stream.

Console.time and Console.timeend are about time.

If you have nothing to do, you can carry out the above mentioned method again.

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.