examples from book JavaScript Patterns