various Javascript idioms in a single file