sample code from 'Javascript: The Good Parts'