/** * Object Speaker * An object representing a person who speaks. */ var Speaker = { init: function(options, elem) { // Mix in the passed in options with the default options this.options = $.extend({},this.options,options); // Save the element reference, both as a jQuery // reference and a normal reference this.elem = elem; this.$elem = $(elem); // Build the dom initial structure this._build();..
Built-in Literals var o= new object(); var o={} var a= new array(); var a = []; var re= new RegExp( "[a-z]", "g"); var re=/[a-z]/g; var s = new String var s = ""; var n = new Number(); var n = 0; var b = new Boolean(); var b = false; throw new Error("uh-oh"); throw { name : "Error", message : "uh-oh" }; or throw Error("uh-oh");
정의 A. 고차원의 모듈은 저차원의 모듈에 의존하면 안된다. 이 두 모듈 모두 다른 추상화된 것에 의존해야 한다. B. 추상화 된 것은 구체적인 것에 의존하면 안 된다. 구체적인 것이 추상화 된 것에 의존해야 한다. ㅁ -- ㅁ ㅁ -- ㅁ | | ㅁ ㅁ function buttonClient() {}; buttonClient.prototype.turnOn = function(){ throw new Error("This method must be overwritten!"); }; buttonClient.prototype.turnOff = function(){ throw new Error("This method must be overwritten!"); }; function lamp() { buttonCl..
* 요청 내역을 객체로 캡슐화하여 클라이언트를 서로 다른 요청 내역에 따라 매개 변수화 할 수 있습니다. 요청을 큐에 저장하거나 로그로 기록 할 수 도 있고 작업취소 기능을 지원 할 수 도 있습니다. var oSimpleRemote = new SimpleRemoteControl(); var oLight = new Light(); var oLightCommand = new LightOnCommand(oLight); oSimpleRemote.setCommand(oLightCommand); oSimpleRemote.buttonWasPressed(); oSimpleRemote.buttonUndoWasPressed(); // Light var Light = function(){ this.bOn = false; }..