Welcome to %s forums

<No. 1 Community for developers, by developers/>

Login Register

How to console or print anything WITHOUT using console.log?

Get support on JavaScript,jQuery, AJAX and other related technology.
Post Reply
admin
Site Admin
Posts: 45

How to console or print anything WITHOUT using console.log?

Post by admin » Sun Oct 20, 2019 5:55 pm

In addition to the console.log viewtopic.php?f=8&t=109method, modern browsers also support similar methods:
console.info – small informative icon (i) appears on the left side of the printed string(s) or object(s).
console.warn – small warning icon (!) appears on the left side. In some browsers, the background of the log is yellow.
console.error – small times icon (⊗) appears on the left side. In some browsers, the background of the log is red.
console.timeStamp – outputs the current time and a specified string, but is non-standard:

Code: Select all

console.timeStamp('msg');
Displays:
00:00:00.001 msg
console.trace – outputs the current stack trace or displays the same output as the log method if invoked in the global scope.

Code: Select all

function sec() {
first();
}
function first() {
console.trace();
}
sec();
Displays:
first
sec
(anonymous function)

Image
The above image shows all the functions, with the exception of timeStamp , in Chrome version 56.
These methods behave similarly to the log method and in different debugging consoles may render in different colors or formats.

In certain debuggers, the individual objects information can be further expanded by clicking the printed text or a small triangle (►) which refers to the respective object properties. These collapsing object properties can be open or closed on log.

Post Reply