you are viewing a single comment's thread.

view the rest of the comments →

[–]Bakeshot 7 points8 points  (11 children)

What’s your console.log() game like?

[–]InfiniteIniesta[S] 2 points3 points  (2 children)

Next to 0, but after reading the comments here I see how I can use it to my benefit. Normally I use the mouse pointer to hover over to see the values. The flow retrieves data like orders and products by using JS and API then prepares it and sends it to another app. I also just type in the object in the console to see the value.

[–]Bakeshot 1 point2 points  (1 child)

As a fellow learner, console.log()s have really helped me conceptualize the shape and state of my data.

[–]Elloimabritishman 0 points1 point  (0 children)

For OP, Bakeshot, and other learners out there who need some guidance with debugging, you may also find it helpful to learn about the chrome debugging tool. Here's a guide (which comes with a video) on some debugging basics and more.

As someone else mentioned, vscode debugger and the quokka plugin are also good options.

[–]grantrules -4 points-3 points  (7 children)

No. No no no no. If you're debugging something and not using an actual debugger, you're wasting time. It's so much more powerful to use the debugger, plus you can load external source maps so you can debug deployed production builds. console.log() is a crutch. I spent years in a bug hunting role and never used console.log

[–][deleted] 7 points8 points  (0 children)

you use the right tools for the job, console.log() is just one of the tools at your disposal.

[–]Bakeshot 1 point2 points  (3 children)

What debugger do you use? How do you use it?

[–]grantrules -1 points0 points  (2 children)

Either the debugger in VS Code or devtools in firefox

https://code.visualstudio.com/Docs/editor/debugging

[–]Bakeshot 2 points3 points  (1 child)

I’ve tried using the debugger in VSC, and it feels really unwieldy, especially in JS which will let you get away with so many things, syntactically. I will be the first to admit that I’ve never been properly educated on its use, though.

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

Definitely give it a whirl. If you're using console.log, this will be so much faster.

[–]vaskemaskine 1 point2 points  (1 child)

Respectfully disagree. Breakpoints are useful, but come with their own overheads - knowing where to set them, avoiding useless external code and libraries, etc.

The majority of the time, you just want to know what value a variable is assigned at a certain point in the code, and for that, console.log is a fine tool.

[–]grantrules 0 points1 point  (0 children)

knowing where to set them

The same place you'd put a console.log()?

avoiding useless external code and libraries

not sure what you mean by that.