Here are 5 must-know console object methods and tricks!
Are you still using console.log for all your JavaScript debugging needs in 2023?
It's tim...
For further actions, you may consider blocking this person and/or reporting abuse
Great article, useful to know, but
console.log
isn't a "big no-no" at all, it just depends on how you use it - most of the time I just use it as a temporary statement to debug something, and when I'm done I delete it from my code :)Marketing bro, you have to know how to sell your post. Also, the man tries to talk about people who only use "console.log" and don't know the other methods that the JavaScript "console" object has.
But yes, console.log is also a good method and can be used together with these others, since although the others are good, for example to print any type of data on the console (boolean, object, string, etc.) it's better to use console.log.
Yeah you're right, the "big no-no" makes for a catchy title, it draws attention ... well yes, I purely insert
console.log
's to dump a piece of data in order to debug an issue, once I've solved it myconsole.log
statement will be promptly deleted from the code ... anyway, these new console methods are definitely cool!Yeah, most people most of the time (even myself) will continue using the console.log. It is not a bad thing. This is just a way to raise some attention in other methods that sometimes we can use. I like to use for example the time and assert ones.
I've used the time one as well, it's great (to time a piece of 'synchronous' JS code)
Yes logging is very okay.
However in my most scenarios I just use
console.debug()
andconsole.error()
instead (so most of the logging will be invisible to the end user -> "verbose" mode should be enabled in order to see the debug logs).Here's an example of how I use logging most of the times:
Yeah that could be very useful, especially if you could make the logs available in a production app (that would require some sort of periodic Ajax call to sync the logs to a backend) ... I assume that
console.debug
has negligible overhead if it's disabled/non-verbose?Yes, that's right. In production we should not only use console.log/debug/anything as they're only accessible on end-user's browser... instead, we should (also) use a proper Node.js logging library (that could provide full timestamps as well), such as the ones mentioned on this StackOverflow thread. (Also keep in mind that some apps should never use console.logging in the browser, as sensitive information could be shown/accessible by end user)
Also on end-user's browser,
console.debug
are still written on the console (eg. DevTools), but they are just not visible if "Verbose" is not checked from options.Yea I was gonna say the same thing, other than the cringy click baity title, the article is good as well
Console assert is awesome! Doesn't polute your console when everything is running fine and gives you enough data to debug when something goes wrong
Yeah! It is a really good method
Or better yet, Don't use console methods 😬, use the inbuilt browser debugger :)
Even better! Although I find myself going back always to the usual console functions 😂
I just prefer to set a debugger and then do everything inside the Dev Tools and next on copy the insights to my code.
I think it's just I have a bigger overview on what is currently happening inside the app and browser.
I don't use console.log at all
nice and very well written post.
it was already in 2020, and 2015... because you should debugging using other other tools!
these tricks are nice and neat (and definitely helpful sometimes) but if you really want to sharpen your axe please use a proper debugger and breakpoint (and conditional breakpoints) .
Great post! I totally agree that using just console.log in 2023 is a big no-no. With the rapid advancements in technology and the abundance of better debugging tools available, relying solely on console.log is not only inefficient but also outdated. Using more advanced debugging tools not only helps us find and fix errors faster, but also allows us to gain a deeper understanding of our code. Thanks for bringing this important topic to light!
Oh man, those are a bunch of really useful console loggers! I knew some of them but not all!
Going to have to update my postfix completions
Thanks for the amazing comment! I was also amazed when I found all of them!
Awesome, Very useful article
Very great article
I don't use front-end much in my work, but when I do I hate the Console.log. This article is awesome and learned me a lot!
Thank you for the awesome comment!
very useful
Thanks. I was already using time console.time to have an idea on performance but for others I either had not used or didn’t know about… definitely a very beneficial content.
Thank you! Yeah, time is really useful. I also like the assert one.
Great article, Thanks for sharing
Nice post, those are really useful console loggers.
Thanks!
Very awesome broo
To be honest, all the methods described in the article were in browsers for ~10 years.
According to our experience, nobody uses them, because when you need just to log,
console.log
is enough. If it is not enough (e.g. for backend logs), you use some logging libraries likewinston
: github.com/winstonjs/winstonOkay, so, counterpoints:
console.
's before they ever touch your repo.console
output. If your deployment/minifier/uglifier doesn't scrub them you're (or more likely CICD) is doing something wrong.Don't misunderstand me: it's a good review of console methods. But I would argue that ANY way you're using console is a no-no IN PRODUCTION, and PRIOR to Prod is a non-issue.
The best debugging tool is the one you know best.
console.log
offers nice out-of-the-box formatting and works fine in many situations, making it a far cry from a "big no-no".Nice :) But does look very similar to my article 😉
Fun with console.log() 💿
Alicia Sykes ・ Nov 20 '22 ・ 9 min read
And has an appropriate title as well. Thank you for not click-baiting us. :)
This is article is really useful. These features are required in day to day debugging, I use to implement them manually.
Thank you for sharing this.
console.group and console.table is awesome
Very good read. Thanks forr the article!
think,i was already to use
Thanks for JavaScript console information.
Clickbait title :-(
Omg, great article!! today i just use
console.log
Thank you for this article, I learned some tricks I didn't know, like
console.time
, which I will probably abuse from now on :)Too many cool stuff here , Thanks !! 💖
Oh my gosh, there's a console.assert function? Why did I spend all this time trying to get mocha and jest working with 11ty? This is awesome!
Thanks, i forgot about console.table() it's very usefull. I didn't know some other methods.
Theses method is very good, it's obvious that According to the different scenarios to cope with different API.good 🥸
Great article! Congratulations
I was always using only log and error but now will use these above as well..... thanks for great article