Jump into concepts and practice - no test required
or
Recommended
Test this pattern10 questions across easy, medium, and hard to know if this pattern is strong
Recall & Review
beginner
What is the purpose of the Node.js built-in debugger?
The Node.js built-in debugger helps you find and fix errors in your code by letting you pause execution, inspect variables, and step through your program line by line.
Click to reveal answer
beginner
How do you start the Node.js built-in debugger from the command line?
You start it by running your script with the command node inspect your_script.js. This launches the debugger interface in the terminal.
Click to reveal answer
intermediate
What command do you use in the Node.js debugger to continue execution until the next breakpoint?
Use the cont or c command to continue running until the next breakpoint or pause point.
Click to reveal answer
intermediate
Explain the use of the repl command in the Node.js debugger.
The repl command opens a Read-Eval-Print Loop where you can type JavaScript expressions to inspect or change variables while paused.
Click to reveal answer
beginner
How can you set a breakpoint in your Node.js code to use with the built-in debugger?
Insert the statement debugger; in your code where you want to pause. When running with the debugger, execution will stop at that line.
Click to reveal answer
Which command starts the Node.js built-in debugger?
Anode inspect script.js
Bnode debug script.js
Cnode run script.js
Dnode start script.js
✗ Incorrect
The correct command is node inspect script.js to start the built-in debugger.
What does the cont command do in the Node.js debugger?
ARestarts the program
BStops the debugger
CPrints all variables
DContinues execution until the next breakpoint
✗ Incorrect
The cont command resumes running the program until it hits the next breakpoint or finishes.
How do you pause execution at a specific line in your code when debugging?
AAdd <code>pause;</code> in code
BAdd <code>debugger;</code> in code
CAdd <code>stop;</code> in code
DAdd <code>break;</code> in code
✗ Incorrect
The debugger; statement pauses execution when the debugger is running.
What is the purpose of the repl command in the Node.js debugger?
ARuns the program
BExits the debugger
CAllows interactive JavaScript evaluation
DSets a breakpoint
✗ Incorrect
The repl command opens an interactive prompt to evaluate JavaScript expressions while paused.
Which of these is NOT a feature of the Node.js built-in debugger?
AAutomatically fix bugs
BInspect variable values
CStep through code line by line
DSet breakpoints
✗ Incorrect
The debugger helps find bugs but does not automatically fix them.
Describe how to use the Node.js built-in debugger to find a bug in your code.
Think about starting, pausing, stepping, and checking values.
You got /4 concepts.
Explain the role of the debugger; statement in Node.js debugging.
It's a special line you add to pause your program.
You got /3 concepts.
Practice
(1/5)
1. What is the primary purpose of the Node.js built-in debugger?
easy
A. To pause and inspect code execution to find bugs
B. To speed up the execution of Node.js programs
C. To automatically fix syntax errors in code
D. To deploy Node.js applications to the cloud
Solution
Step 1: Understand the debugger's role
The Node.js built-in debugger allows developers to pause code execution and inspect variables and flow.
Step 2: Compare options to debugger purpose
Only To pause and inspect code execution to find bugs describes pausing and inspecting code to find bugs, which matches the debugger's function.
Final Answer:
To pause and inspect code execution to find bugs -> Option A
Quick Check:
Debugger purpose = pause and inspect [OK]
Hint: Debugger = pause and inspect code to find bugs [OK]
Common Mistakes:
Thinking debugger speeds up code
Confusing debugger with auto-fix tools
Assuming debugger deploys apps
2. Which command correctly starts the Node.js built-in debugger for a script named app.js?
easy
A. node debug app.js
B. node run app.js
C. node inspect app.js
D. node start app.js
Solution
Step 1: Recall debugger start commands
The modern way to start the Node.js debugger is using node inspect followed by the script name.
Step 2: Check each option
node inspect app.js uses node inspect app.js, which is correct. node debug app.js uses deprecated node debug. Options B and D are invalid commands.
Final Answer:
node inspect app.js -> Option C
Quick Check:
Start debugger = node inspect [OK]
Hint: Use 'node inspect' to start debugger, not 'node debug' [OK]
Common Mistakes:
Using 'node debug' which is deprecated
Using 'node run' or 'node start' which don't start debugger
Confusing command syntax order
3. Given this code snippet with debugger statements:
function add(a, b) {
debugger;
return a + b;
}
console.log(add(2, 3));
What happens when you run node inspect script.js on this file?
medium
A. The program runs without pausing and prints 5 immediately
B. The program crashes with an exception
C. SyntaxError occurs due to debugger statement
D. Execution pauses at the debugger line before returning the sum
Solution
Step 1: Understand debugger statement effect
The debugger; statement causes the debugger to pause execution at that line when running under a debugger.
Step 2: Analyze program flow
Running node inspect pauses at the debugger; line inside add before returning the sum, allowing inspection.
Final Answer:
Execution pauses at the debugger line before returning the sum -> Option D
Quick Check:
Debugger statement pauses execution under debugger [OK]
Hint: Debugger statement pauses code only when debugger runs [OK]
Common Mistakes:
Thinking debugger statement causes syntax error
Assuming program runs without pause under debugger
Confusing debugger statement with console.log
4. You run node inspect app.js but the debugger does not pause at your debugger; statement inside a function. What is a likely cause?
medium
A. The debugger command is misspelled
B. You forgot to save the file after adding the debugger statement
C. Node.js version does not support debugger
D. Debugger statements only work in browser JavaScript
Solution
Step 1: Check file changes
If the file was not saved after adding debugger;, the running code won't include it, so debugger won't pause.
Step 2: Evaluate other options
Debugger command spelling doesn't affect pause at debugger;. Node.js supports debugger in recent versions. Debugger statements work in Node.js, not only browsers.
Final Answer:
You forgot to save the file after adding the debugger statement -> Option B
Quick Check:
Unsaved file = debugger ignored [OK]
Hint: Always save files before debugging to include changes [OK]
Common Mistakes:
Assuming debugger statements only work in browsers
Ignoring file save before running debugger
Blaming Node.js version without checking
5. You want to debug a Node.js script and step through each line inside a loop. Which command should you use after starting node inspect script.js to move to the next line without entering functions?
hard
A. next
B. cont
C. step
D. out
Solution
Step 1: Understand debugger commands
cont continues running until next breakpoint, step enters functions, next moves to next line without entering functions, out steps out of current function.
Step 2: Choose command for stepping through loop lines
To move line by line in the current function (like inside a loop) without entering called functions, next is the correct command.
Final Answer:
next -> Option A
Quick Check:
Step over lines = next [OK]
Hint: Use 'next' to step over lines without entering functions [OK]