Code from Crockford's "Javascript: The Good Parts"