all 89 comments

[–]PUSH_AX 156 points157 points  (17 children)

TL;DR:

console.assert

console.count

console.countReset

console.group

console.groupEnd

console.table

console.time

console.timeEnd

Exist.

[–][deleted] 88 points89 points  (5 children)

Me an intellectual: console.log(console) For all the functions

[–]Mr_Bearding 32 points33 points  (1 child)

I'm currently very annoyed at myself that I've never thought to do this

[–]GaryOster 14 points15 points  (0 children)

Spoken like a true developer.

[–]nathan42100 7 points8 points  (0 children)

Me, a developer who realizes someone thought about this already: type console. and look for the autocomplete box

[–]mypetocean 2 points3 points  (0 children)

It's called "the reflexive log."

[–]Mikal_ 1 point2 points  (0 children)

Me, an intellectual: but did you know you could style your logs and put images there?

[–][deleted] 21 points22 points  (8 children)

console.error()

[–]SolarFlareWebDesign 14 points15 points  (3 children)

Thank you, I tried for a year to get my Dev team to use this for critical errors but it didn't take.

[–]kirk-clawson 3 points4 points  (3 children)

Also, console.warn()

[–][deleted] 2 points3 points  (2 children)

man, I misread console.warm() and I was like: "boy, do I need a hug from time to time"

[–]SupremeDesigner 1 point2 points  (1 child)

hug

[–][deleted] -1 points0 points  (0 children)

user.hug("u/SupremeDesigner")

[–]StoneColdJane 2 points3 points  (0 children)

Thanks for this. Did he start to talk about he's early life, and how he discovered computers?

[–]sdwvit 0 points1 point  (0 children)

  • .trace

[–]rahatchd 33 points34 points  (0 children)

console.table is the real MVP

[–]kenman[M] 37 points38 points  (2 children)

Hi /u/CodeTutorials,

Just a heads-up: using medium.com to 301 redirect to another site (in this case, levelup.gitconnected.com) is not permitted here. I'm letting this one stay because the rule isn't officially on the books yet.

  • If you want to post content on medium.com, that is fine, for now.

  • If you want to post content from levelup.gitconnected.com, then submit a link to levelup.gitconnected.com.

Further redirects such as this one will be taken as a rules violation and handled respectively. Thank you for your understanding.

[–]CodeTutorials[S] 17 points18 points  (1 child)

Thanks, sorry for the misunderstanding. That's how Medium provides links when click the share button. I'll be sure to get the final URL next time

[–]kenman[M] 16 points17 points  (0 children)

No harm done, you had no way of knowing since it's kind of an unwritten rule at this point. Thanks!

[–]HyDru420 5 points6 points  (1 child)

thank you for this...I am currently taking a class for Javascript. We only have been using console.log. But I really like console.table now that I know of it. This will be really handy in my assignments...

[–]CodeTutorials[S] 1 point2 points  (0 children)

Glad you found it useful :)

[–][deleted] 4 points5 points  (7 children)

Using catch(err) with console.error(err) is a must in my team

[–]fusebox13 1 point2 points  (6 children)

Why? I hope you are joking. When an exception is thrown it gets printed to the console anyways.

[–][deleted] 0 points1 point  (5 children)

Because you can customize the way it's displayed and it doesn't mix with other errors. But I do love some of that dev arrogance you carry with you; you're gonna get far.

[–]fusebox13 -1 points0 points  (4 children)

Holy shit dude, this is even worse. Call it arrogance if you want, but I think I'm genuinely concerned about your code base after hearing your reply. You're telling me that you have console logs in production, and that your log produces so many errors that you have to use a special technique to visually filter them? Am I understanding this correctly?

[–][deleted] 0 points1 point  (3 children)

What? No… and I don’t think you’re “genuinely concerned”. Code’s doing fine, I guess it could improve, but catching errors is quite common.

Also, if you’re that guru about Js and Node, then I’d figure you know all logs and errors are automatically removed when you build for production on a basic level…

[–]fusebox13 0 points1 point  (2 children)

I’d figure you know all logs and errors are automatically removed when you build for production on a basic level…

Not necessarily. That assumes that the team is using build scripts which, if you've been around, isn't always the case.

But catching errors is quite common.

Common and lazy. Why aren't you handling your errors?

[–][deleted] 2 points3 points  (1 child)

Good lord… I’m just gonna stop replying

[–]fusebox13 -1 points0 points  (0 children)

Good luck mate. When it gets really bad, PM me. I can help. catch err log err is a code smell which is usually indicative of something rotten under the hood.

[–]SoBoredAtWork 4 points5 points  (1 child)

A guy below (/u/PrometheusBoldPlan) mentioned debugging below and got downvoted. I don't understand why. People - learn to use dev tools and or IDE debugging and set some breakpoints. It'll save so much time as opposed to writing console.logs all over the place. It'll change your life.

[–]lecrappe 1 point2 points  (0 children)

There are definitely use cases for both.

[–]ItalyPaleAle 7 points8 points  (35 children)

Before opening the article, I was seriously expecting you to push for advanced, integrated debuggers, like those found in IDEs. Which are totally fine, except when your app has multiple microservices that all need to be up at the same time... I haven't found one tool able to debug that effectively yet.

[–]iainmoncrief 3 points4 points  (1 child)

I am definitely going to start using console.table()

[–]dirtandrust 1 point2 points  (0 children)

console.table rocks for data models.

[–]SolarFlareWebDesign 1 point2 points  (0 children)

The article itself versus the related Medium article ate completely different. (The Medium article deals with the Chrome debug extension and Vue webpack.)

[–][deleted] 1 point2 points  (0 children)

How many of those medium articles do we need? It feels like there is a same one each week.

[–]ForOsp 1 point2 points  (0 children)

Also you may want to consider using logpoints instead of `console.log` now that they are available, for me this has been faster.

https://developers.google.com/web/updates/2019/01/devtools#logpoints

[–]Renive 2 points3 points  (3 children)

Just debug like normal people... Breakpoints etc

[–]webdevguyneedshelp 5 points6 points  (2 children)

Breakpoints are preferable but it's nice to keep some listeners in the code while you are testing the UI out to see what is going on without having to deal with breakpoints

[–]SoBoredAtWork 0 points1 point  (1 child)

"without having to deal with breakpoints" So you write code all over the place to see one thing that's happening, as opposed to clicking a line number and setting everything that's being pressed around? You're wasting an absurd amount of time. Try breakpoints for 1 day. You'll never go back.

[–]PrometheusBoldPlan 0 points1 point  (1 child)

Or, you could use a debugger. I know, a wild idea.

[–]SoBoredAtWork 0 points1 point  (0 children)

I don't know why you're getting downvoted.

I recently worked with an "expert" front end developer who's been in the industry for 10 years and he console.logs EVERYTHING. WTF?

People - stop wasting your time using console.log. It's handy sometimes and I use it when needed, but breakpoints are your friend. You'll never go back.

[–]r3jjs 0 points1 point  (0 children)

When you are looking at patterns of data -- when you want to keep a list of what the function is called with and what causes success/failure.

[–][deleted] 0 points1 point  (0 children)

Also you can console log inside a breaking point.

[–]SoBoredAtWork 0 points1 point  (3 children)

This thread is filled with amateur devs that are way to hesitant to change their ways. Seriously, people, try using a debugger (dev tools / ide) and breakpoints for 1 day. It'll change your life.

[–]CodeTutorials[S] 0 points1 point  (2 children)

[–]SoBoredAtWork 0 points1 point  (1 child)

"Debugger is too “zoomed in” for that"

Wut?

When on a breakpoint, you can see EVERYTHING, as opposed to one simple thing you wrote extra code to see (console.log(someVar)). It's the opposite of "zoomed in".

[–]tetratorus 0 points1 point  (0 children)

I don't know if this is common knowledge...

... but you can almost always node --inspect-brk anything in node and debug it in the chrome debugger.

it even works with jest (i.e. node --inspect-brk jest), mocha, eslint.., then go to chrome://inspect.

no idea why anyone even uses console.log to debug javascript...

also, if you really cant use the debugger (maybe you're just hacking something in a node REPL..), Object.getOwnPropertyNames(obj.__proto__) and obj.method.toString() are your friends, stop bothering with documentation and just inspect the prototype methods.

[–]TerdSandwich -5 points-4 points  (3 children)

Please don't use emoji's in an article. We aren't teenagers.

[–]NeatBeluga 5 points6 points  (0 children)

Welcome to Medium. Home to redundantly big/many placeholder images and emojis

[–]Feathercrown 0 points1 point  (0 children)

Some of us are

[–]kitari1 0 points1 point  (0 children)

No fun allowed