handoflixue comments on What are you working on? April 2012 - Less Wrong

1 Post author: David_Gerard 01 April 2012 06:40PM

You are viewing a comment permalink. View the original post to see all comments and the full post content.

Comments (60)

You are viewing a single comment's thread. Show more comments above.

Comment author: handoflixue 03 April 2012 08:52:58PM 0 points [-]

Unfortunately, I do Javascript using notepad, so I can't really help you on tools.

I'd usually just write a "UnitTest" function and put my code there. From the browser, you can directly invoke a function, so you'd just do "UnitTest();" or "UnitTest_Module8();" and have them display results in the form of alerts or such.

Another useful technique is to add a label or textbox to the HTML, and then keep running debug information there, for tracking variable that you suspect might be getting set wrong. I'd also often scatter alerts through my code, just so I could tell "Okay, it has reached this point in the code" or "Okay, at this point, x=5"

IMO, the major power of javascript is the ability to run commands "on the fly" from the browser itself, and the ability to very quickly modify the source code and re-run the program.