Andrew Zaw
Andrew Zaw

Reputation: 814

Debugging and checking what variables are equal to in production

So I've been coding for a while now in school, and I'm having my first introduction into a real working code base at my new job. When it comes to debugging, like if I want to find out what a certain variable is equal to, I'll often just console.log() things out and hope that something useful comes out of it.

It seems really inefficient considering how many moving parts there are in the code. Most of the time, it works eventually, but it feels so barbaric just editing the code over and over and looking at the browser's console until something useful comes out, and it feels like there has to be a better way to debug in a production environment. I am specifically using Ember.JS, but this question would apply to any framework like React or Angular or Node.

Upvotes: 0

Views: 271

Answers (2)

Rafael Mezquita
Rafael Mezquita

Reputation: 17

If you use VS Code, you can run Node apps in debug mode then select Node.js.

mode debug

Upvotes: 1

Elias Schablowski
Elias Schablowski

Reputation: 2812

There are many tools out there to debug JS, the most "basic" being the debugger in your browser. Some tools go further also, for example VSCode has a slew of extensions that open and control the browsers debugger.

Chrome: https://developers.google.com/web/tools/chrome-devtools/javascript/

Firefox: https://developer.mozilla.org/en-US/docs/Tools/Debugger

Edge: https://learn.microsoft.com/en-us/microsoft-edge/devtools-guide/debugger

Safari also has one in the develop menu but there is no site describing it in detail - it is located in the sources pane

Upvotes: 1

Related Questions