# 设计模式

## 引言

有关设计模式的文章在网络上到处都有，但是以 JavaScript 为例的设计模式文章却较为稀少，而且其中有很多感觉是在强行将别的语言的设计模式改为 JavaScript 来实现，不仅难以理解还损失掉了 JavaScript 的优势点。

因此想跟着曾探老师的脚步，再加上自己的理解，整理一份包含 ES6 语法的 JavaScript 设计模式的手册。

我想整理的也并不是一片冗长的知识文档，而是你稍微看一下就可以知道此设计模式的**模式动机**和**实现思路**及**应用场景**

## 原则

找出程序中的变化，并将变化封装起来，**不为了去用设计模式而去使用设计模式**。

## 参考

曾探老师的 《JavaScript 的设计模式开发与实践》

[图说设计模式](https://design-patterns.readthedocs.io/zh_CN/latest/index.html)


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://haoqinn.gitbook.io/handbook-of-design-pattern/master.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
