Debugging: What is step into?
In a nutshell
Step into will make the debugger descend into any method calls on the current line.
If there are multiple method calls on the current line, they’ll be visited in order of execution. If there are no method calls, this will be the same as step over.
Step into is broadly equivalent to visiting every line of execution as the interpreter would.
When to step into?
When you want to see what a method on the current line does (e.g., to check if it changes the value of a variable as you’d expect).
Example use
Given the following code:
function main() {
var s = foo();
bar(s);
}
function foo() {
return "hi";
}
function bar(s) {
var t = s + foo(); // Debugger is currently here
return t;
}
If your debugger enters through main()
and is now on the first line of bar
, then telling the debugger to “step into” will proceed it into the foo
call so that the current line becomes the return "hi";
statement within foo
.
Sources
Thanks for your comment 🙏. Once it's approved, it will appear here.
Leave a comment