Debugging code in Deno
Even when we're following best practices and doing our best to write simple, clean code, any relevant program is very likely to need debugging once in a while.
Mastering the ability to quickly run and debug code is one of the best ways to improve your learning curve for any technology. This skill makes it easy to test and understand how stuff works by trial and error and fast experimentation.
Let's learn how can we debug our code.
The first step is to create a second program. Let's add a couple of variables that we can inspect later. The main objective of this program is to return the current time. We'll be using the already known Date
object to do this. Let's call this file get-current-time.js
, like so:
const now = new Date(); console.log(`${now.getHours()}:${now.getMinutes()}: ${now.getSeconds()}`);
What if we want to debug the value of the now
variable before it prints to the console? This is where debugging...