本文接着介绍11种行为型模式里的备忘录模式.观察者模式.状态模式. 一.备忘录模式 在不破坏封装性的前提下,捕获一个对象的内部状态.并在该对象之外保存这个状态.这样以后就能够将该对象恢复到原先保存的状态.还是比較好理解的. 1.Memento 备忘录存储原发器对象的内部状态,这个类就是要存储的对象的状态.状态须要多少个变量,在Memento里就写多少个变量. public class Memento { private String state; public Meme*to(String st
少废话,先上代码: function Human() { } Human.prototype.name = "成吉思汗"; Human.prototype.sex = "男"; Human.prototype.say = function () { alert(this.name); } var man = new Human(); man.say(); //成吉思汗 var woman = new Human(); woman.say(); //成吉思汗 aler