Troubleshoot by Tracing Code within JavaScript


show more Tracing through a section of code is an effective way to troubleshoot errors in not only JavaScript, but other languages as well. In Foundations of Programming Fundamentls, you'll discover functions to debug code, as well as the tracing method for debugging that can simplify the identification and fixing of bugs. show less
please wait ...

Tracing through a section of code

So let me show you a simple low-tech way of debugging some JavaScript code and this concept also works in other languages. I am going to open up an example file of JavaScript that I have. There are a few lines here but there's not a lot of complex stuff going on, we've talked about every single piece here. I am defining four functions at the top of my JavaScript. firstFunction, secondFunction, thirdFunction and fourthFunction and they're basically just calling each other in order. The reason that I am doing this is I want to follow a flow.

The final function will actually change the HTML of the headline. So the functions that are defined when the page loads, these won't be executed, but it will know about them. The two lines of code that I will run is this one where I am grabbing that headline element and then I am adding an event handler to it. I am saying when somebody clicks the headline, call firstFunction. firstFunction should call secondFunction, secondFunction shoul...

Tracing through a section of code
Video duration: 7m 5s 4h 47m Beginner

Viewers:

Tracing through a section of code is an effective way to troubleshoot errors in not only JavaScript, but other languages as well. In Foundations of Programming Fundamentls, you'll discover functions to debug code, as well as the tracing method for debugging that can simplify the identification and fixing of bugs.

Subjects:
Developer Web
Author:
please wait ...