How to encrypt JavaScript code?

Debugging Javascript code -How to trace Javascript code using Firebug?

  • Hello, I want to know how to trace Javascript with Firebug? Many times Jquery codes are based on some class or id & its being called using some jQuery code & I want to know which code is getting called when I click on some element. Thanks.

  • Answer:

    To debug javascript in Firebug (available when pressing F12), you have to understand its tools: Watch Stack Breakpoints Below is a picture of firebug debugging some random code (from one of my pet projects) that I paused in the browser to explain these concepts: The Watch in the picture is on the right panel and it contains the variables and functions that you can click and inspect. There are 2 columns - the object itself, and the value it contains. Using Watch lets you inspect variables, to observe what value they contain at certain times in your debugging session; to actually activate the watch and make this happen, you have to pause execution of your javascript code by using breakpoints. The breakpoint is the small red dot on the left edge of the left panel. In the picture above we have set 3 breakpoints; you set these by clicking on that spot. You can add breakpoints inside functions which tell the execution - "pause there, I want to inspect what the variables contain at that particular (break)point". You can set as many breakpoints as you want. Notice that in the picture above I paused on the for loop - you can see where the code execution currently is, because that's where the small yellow arrow inside the breakpoint is. From that point on, I can press the F8 key to skip to the next breakpoint or go step-by-step with the F10 key - the F8 skips to the next breakpoint if there is one, or executes everything until the end if there is no further breakpoint. If you are used to Visual Studio's debugging and continue execution with the F5 key, it does not work in the browser - pressing F5 will reload your page, so you need to use F8 instead of F5 for the continue command. Also - pausing the code on that breakpoint populated my watch window with whatever details were detected as available to show in there - I can click on the New watch expression to add my own watch (like some jquery variable or anything that I want to inspect); if, for example, I want to see what the memberKey variable contains, I have to press F10 so that the execution enters my for loop and shows what memberKey contains (notice how memberKey is currently undefined) Finally, the Stack can be seen on the picture below and it shows how execution got up to that point, which means you can see the call stack - what method called what, in order to reach that point. The oldest method on the stack is the last one and the newest is on top (the newest is also where your execution is located at that point). Happy coding.

Anonymous at Quora Visit the source

Was this solution helpful to you?

Related Q & A:

Just Added Q & A:

Find solution

For every problem there is a solution! Proved by Solucija.

  • Got an issue and looking for advice?

  • Ask Solucija to search every corner of the Web for help.

  • Get workable solutions and helpful tips in a moment.

Just ask Solucija about an issue you face and immediately get a list of ready solutions, answers and tips from other Internet users. We always provide the most suitable and complete answer to your question at the top, along with a few good alternatives below.