I was wondering if there are any alternatives to writing something to the console without using console messages. My project removes all console statements before finalizing the build, but in a unique case I need to find a way to display something to the user via the console. Is this even possible without console statements?
They are almost identical - the only difference is that debug messages are hidden by default in recent versions of Chrome (you have to set the log level to Verbose in the Devtools topbar while in console to see debug messages; log messages are visible by default).
console. log() is a function used to print information to the console. return on the other hand is a call to pass some value back up to where the call was made.
document. write() is used to write HTML to the document using Javascript. console. log() is used to log or display something to the Javascript console.
The only notable difference between the two is that, when printing an object, console. log gives special treatment to HTML elements, while console.
You can write to console only through Console object. The Console object provides access to the browser's debugging console.
console.log("Failed to open the specified link")
You can use other methods for debugging: info()
console.info('Debug message');
warn()
console.warn('Debug message');
error()
console.error('Debug error message')
time()
console.time(label);
table()
console.table(["apples", "oranges", "bananas"]);
trace()
console.trace();
As for me, I like using console.table() and console.group()
Additional info on the MDN - https://developer.mozilla.org/en-US/docs/Web/API/Console and on the article https://medium.freecodecamp.org/how-to-get-the-most-out-of-the-javascript-console-b57ca9db3e6d
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With