var Interface = function (name, methods) { this.name = name; // copies array
this.methods = methods.slice(0);
};
Interface.checkImplements = function (obj, interfaceObj) { for (var i = 0; i < interfaceObj.methods.length; i++) { var method = interfaceObj.methods[i]; if (!obj[method] || typeof obj[method] !=="function")
};var firstCar = new Product("Super Car X11",20000,"Car");console.log(firstCar.getName()); // Super Car X11delete Product.prototype.getPrice;var secondCar = new Product("Super Car X12",30000,"Car"); // Error: Interface not implemented!
EventManager.fireEvent = function(eventName, eventProperties) { if (!listeners[eventName]) return; for (var i = 0; i < listeners[eventName].length; i++) {
listeners[eventName][i](eventProperties);
}
};
EventManager.addListener = function(eventName, callback) { if (!listeners[eventName])
listeners[eventName] = [];
listeners[eventName].push(callback);
};
EventManager.removeListener = function(eventName, callback) { if (!listeners[eventName]) return; for (var i = 0; i < listeners[eventName].length; i++) { if (listeners[eventName][i] == callback) { delete listeners[eventName][i]; return;