Appendix A. Up and Running in jsBin and jsFiddle

Most of the examples are JavaScript code snippets, rather than HTML files with script elements. The snippets can be copied directly into jsBin or jsFiddle or, for the most part, run using Node. In this Appendix, I’ll briefly cover the information you’ll need to run the examples successfully.

The Console Is Your Friend

Formally, we should use unit testing for determing application state, but I’ve not found it to be as friendly or helpful as a good old print out of data. In the past, we used alert() to print out values, but now we have the console.

All the main browsers (i.e., Internet Explorer, Firefox, Chrome, Opera, and Safari) have access to a console, as does Node. Here’s a quick cheatsheet:

  • To access the console in Chrome, access the Chrome customize menu, then select Tools→JavaScript Console.
  • To access the console in Opera, click Tools in the menu, then open up Opera Dragonfly and select the Console.
  • In Safari, enable the Develop menu in Safari’s Advanced preferences to access the Console.
  • The Internet Explorer console can be accessed by pressing F12, or selecting “F12 Developer Tools” from the Settings menu.
  • In Firefox, access the console by selecting Developer from the Firefox settings menu, and then choosing “Browser Console”.
  • In Node, output to the console prints to the standard output.

I used console.log() all throughout the book, but there are other methods you can use. Among my other favorites are the following:

  • console.assert(express, ...

Get JavaScript Cookbook, 2nd Edition now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.