Documentation Home

Debugging JavaScripts For CALC 1

The script editor is suitable for simple scripts. For more complicated scripts, you will need a JavaScript Debugger to allow you to step through the script and inspect variables. Fortunately, there are many free JavaScript Debuggers available including, but not limited to, most desktop browsers.

This is a list of guides for using Safari, Firefox and Chrome debuggers:

Sample HTML Pages for Debugging JavaScripts for CALC 1

Below are links to HTML pages that can be used to debug scripts on a desktop browser.

Follow the link to the page.

  1. From the File menu, "Save" the page. Be sure to choose the option to save the HTML. This will be different for each browser.
  2. Open a the HTML file Saved to your desktop.
  3. Enable the debugger for your browser.
  4. In the source there are comments with more instructions.

Safari is used to develop the CALC 1 JavaScripts since they both use JavaScriptCore. But any modern debugger should work fine.

Test-Driven Development

These debugging pages use Test-Driven Development.

The cycle is:

  1. Add a test.
  2. Run all tests and see it the new test fails with the "Run Tests" button.
  3. Write the code to cause the test to pass.
  4. Run tests.
  5. When all tests pass you can "Refactor" (clean up) your code.
  6. Repeat.

When done, save the HTML file for future reference and in case you find a bug later.

If you find a bug, don't fix it until you write a test to reproduce the bug. Then fix the bug. Your previous tests will confirm that the changes to fix the bug did not cause other tests to fail.