JavaScript Patterns (Paperback)

Stoyan Stefanov



What's the best approach for developing an application with JavaScript? This book helps you answer that question with numerous JavaScript coding patterns and best practices. If you're an experienced developer looking to solve problems related to objects, functions, inheritance, and other language-specific categories, the abstractions and code templates in this guide are ideal -- whether you're writing a client-side, server-side, or desktop application with JavaScript.

Written by JavaScript expert Stoyan Stefanov -- Senior Yahoo! Technical and architect of YSlow 2.0, the web page performance optimization tool -- JavaScript Patterns includes practical advice for implementing each pattern discussed, along with several hands-on examples. You'll also learn about anti-patterns: common programming approaches that cause more problems than they solve.

  • Explore useful habits for writing high-quality JavaScript code, such as avoiding globals, using single var declarations, and more
  • Learn why literal notation patterns are simpler alternatives to constructor functions
  • Discover different ways to define a function in JavaScript
  • Create objects that go beyond the basic patterns of using object literals and constructor functions
  • Learn the options available for code reuse and inheritance in JavaScript
  • Study sample JavaScript approaches to common design patterns such as Singleton, Factory, Decorator, and more
  • Examine patterns that apply specifically to the client-side browser environment



這本書由JavaScript專家Stoyan Stefanov撰寫,他是雅虎高級技術人員和YSlow 2.0網頁效能優化工具的架構師。《JavaScript Patterns》提供了實施每個討論模式的實用建議,並附有多個實際範例。您還將了解到反模式:常見的程式設計方法,解決問題時反而帶來更多問題。

- 探索撰寫高品質JavaScript程式碼的有用習慣,例如避免使用全域變數、使用單一var聲明等。
- 瞭解字面值表示法模式作為構造函數的簡單替代方案。
- 發現在JavaScript中定義函數的不同方式。
- 創建超越使用物件字面值和構造函數的基本模式的物件。
- 瞭解JavaScript中可重用程式碼和繼承的選項。
- 學習常見設計模式(如Singleton、Factory、Decorator等)的JavaScript範例。
- 檢視適用於客戶端瀏覽器環境的特定模式。