2.03 - emulating interfaces with duck typing.js
来自「JS设计模式源代码」· JavaScript 代码 · 共 19 行
JS
19 行
// Interfaces.var Composite = new Interface('Composite', ['add', 'remove', 'getChild']);var FormItem = new Interface('FormItem', ['save']);// CompositeForm classvar CompositeForm = function(id, method, action) { ...};...function addForm(formInstance) { ensureImplements(formInstance, Composite, FormItem); // This function will throw an error if a required method is not implemented. ...}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?