console.log("This is a message to print"); // This is a message to print
It uses util.inspect and util.format internally. You can use this to print strings, arrays, objects, or any variable you like. It also supports string substitution just like util.format we studied in the previous lesson. Example:
console.log("2 + 2 equals %d", 4); // 2 + 2 equals 4
Other substitution strings are** %o for an object, *%d **for integer, *%f for floating-point value, and even *%c *for CSS styles. Example:
console.log("%c this is red color log", "color: red"); // prints "this is red color" log but in red color
Of course, it doesn’t have only .log() function. It does provide us a lot of helpful functions in accordance with the message we want to print. Example console.error() for errors, console.table() for printing tables, etc. Let’s look at all of the types in detail.
We are providing robust Node.JS Development Services with expert Node.js Developers. Get affordable Node.JS Web Development services from Skenix Infotech.
With the rapid development in technology, the old ways to do business have changed completely. A lot more advanced and developed ways are ...
You name the business and I will tell you how web development can help you promote your business. If it is a startup or you seeking some...