I came across this answer to a question, which I have posted in full below:
Looks like a lot of complicated javascript and you are not sure where the problem is. Here are some things I would do to try to locate the source of the issue:
You could try using Firebug with Firefox (or any Javascript debugger depending on the browser you are using). You could then set a breakpoint at the line you think is throwing the error.
As you step over the code keep an eye on all relevant variable values and perhaps you will spot a value just before it fails and that might give you a clue to figuring out where the logic error is.
Another idea would be to start building your complex code up from scratch, and testing it step by step as you grow your complexity and perhaps then you will find where you are going wrong. You could try using a Javascript testing tool as you build your code from scratch as well - such as http://jasmine.github.io/
To summarise the paragraphs, we have:
- Your code is complicated
- Use Firebug to investigate your problem
- Look at variables when debugging
- Rewrite your program from scratch
None of these is actually an answer - if it were, couldn't we just automatically write this answer to any question involving JavaScript and be done with answering questions altogether?
It would be an answer if the poster had used these techniques to find the problem and then added a description of how it was done.
I did flag this answer, but the flag was disputed.
So how is this an answer?