JavaScript設計模式:工廠模式(附接口模式代碼)

工廠模式目的:消除類之間的依賴性。 在引入工廠模式之前,咱們先給出接口類的代碼:javascript var Interface = function(name,methods){ if(arguments.length != 2){ throw new Error("expect 2 arguments."); } this.name = name;
相關文章
相關標籤/搜索