Меня попросили перенести часть нашего PHP-кода на JavaScript, чтобы больше наших логика работает на стороне клиента. Я бы хотел простой пример, который показывает:
var Package = {};
Package.Master = function(pValue) {
this.p = pValue;
this.m = function() {
alert("mmmmm");
}
}
Package.Slave = function(pValue) {
// this will inherit from Package.Master
}
// one of the many online examples:
// http://kevlindev.com/tutorials/javascript/inheritance/index.htm
KevLinDev.extend = function(subClass, baseClass) {
function inheritance() {}
inheritance.prototype = baseClass.prototype;
subClass.prototype = new inheritance();
subClass.prototype.constructor = subClass;
subClass.baseConstructor = baseClass;
subClass.superClass = baseClass.prototype;
}
KevLinDev.extend(Package.Slave, Package.Master);