140. var inherit = function (Child, Parent) {
var F = function () {};
F.prototype = Parent.prototype;
Child.prototype = new F();
Child.uber = Parent.prototype;
}
141. var inherit = function (Child, Parent) {
var F = function () {};
F.prototype = Parent.prototype;
Child.prototype = new F();
Child.uber = Parent.prototype;
}
142. var inherit = function (Child, Parent) {
var F = function () {};
F.prototype = Parent.prototype;
Child.prototype = new F();
Child.uber = Parent.prototype;
Child.prototype.constructor = Child;
}
143. var inherit = function (Child, Parent) {
var F = function () {};
F.prototype = Parent.prototype;
Child.prototype = new F();
Child.uber = Parent.prototype;
Child.prototype.constructor = Child;
}
144. classical inheritance
1. Default Pattern
2. Rent-a-Constructor
3. Rent and Set Prototype
4. Share Prototype
5. Temp. Constructor
145. classical inheritance
1. Default Pattern
klass
2. Rent-a-Constructor
3. Rent and Set Prototype
4. Share Prototype
5. Temp. Constructor
146. var Parent = klass(
null,
{
__construct: function () {},
someMethod: function () {}
}
);
var Child = klass(
Parent,
{
__construct: function () {},
childMethod: function () {}
}
);
147. var Parent = klass(
null,
{
__construct: function () {},
someMethod: function () {}
}
);
var Child = klass(
Parent,
{
__construct: function () {},
childMethod: function () {}
}
);
148. var Parent = klass(
null,
{
__construct: function () {},
someMethod: function () {}
}
);
var Child = klass(
Parent,
{
__construct: function () {},
childMethod: function () {}
}
);
149. var Parent = klass(
null,
{
__construct: function () {},
someMethod: function () {}
}
);
var Child = klass(
Parent,
{
__construct: function () {},
childMethod: function () {}
}
);
150. var Parent = klass(
null,
{
__construct: function () {},
someMethod: function () {}
}
);
var Child = klass(
Parent,
{
__construct: function () {},
childMethod: function () {}
}
);
151. var Parent = klass(
null,
{
__construct: function () {},
someMethod: function () {}
}
);
var Child = klass(
Parent,
{
__construct: function () {},
childMethod: function () {}
}
);
152. var Parent = klass(
null,
{
__construct: function () {},
someMethod: function () {}
}
);
var Child = klass(
Parent,
{
__construct: function () {},
childMethod: function () {}
}
);
153. var Man = klass(
null,
{
__construct: function (what) {
console.log('man constructor');
this.name = what;
},
getName: function () {
return this.name;
}
}
);
154. var Man = klass(
null,
{
__construct: function (what) {
console.log('man constructor');
this.name = what;
},
getName: function () {
return this.name;
}
}
);
155. var Man = klass(
null,
{
__construct: function (what) {
console.log('man constructor');
this.name = what;
},
getName: function () {
return this.name;
}
}
);
156. var Man = klass(
null,
{
__construct: function (what) {
console.log('man constructor');
this.name = what;
},
getName: function () {
return this.name;
}
}
);
157. var Man = klass(
null,
{
__construct: function (what) {
console.log('man constructor');
this.name = what;
},
getName: function () {
return this.name;
}
}
);
158. var Man = klass(
null,
{
__construct: function (what) {
console.log('man constructor');
this.name = what;
},
getName: function () {
return this.name;
}
}
);
159. var Man = klass(
null,
{
__construct: function (what) {
console.log('man constructor');
this.name = what;
},
getName: function () {
return this.name;
}
}
);
160. var first = new Man('Adam');
// logs 'man constructor'
first.getName();
// 'Adam'
161. var first = new Man('Adam');
// logs 'man constructor'
first.getName();
// 'Adam'
162. var first = new Man('Adam');
// logs 'man constructor'
first.getName();
// 'Adam'
163. var first = new Man('Adam');
// logs 'man constructor'
first.getName();
// 'Adam'
164. var SuperMan = klass(
Man,
{
__construct: function (what) {
console.log('super man constructor');
},
getName: function () {
var name = SuperMan.uber.getName.call(this);
return 'I am ' + name;
}
}
);
165. var SuperMan = klass(
Man,
{
__construct: function (what) {
console.log('super man constructor');
},
getName: function () {
var name = SuperMan.uber.getName.call(this);
return 'I am ' + name;
}
}
);
166. var SuperMan = klass(
Man,
{
__construct: function (what) {
console.log('super man constructor');
},
getName: function () {
var name = SuperMan.uber.getName.call(this);
return 'I am ' + name;
}
}
);
167. var SuperMan = klass(
Man,
{
__construct: function (what) {
console.log('super man constructor');
},
getName: function () {
var name = SuperMan.uber.getName.call(this);
return 'I am ' + name;
}
}
);
168. var SuperMan = klass(
Man,
{
__construct: function (what) {
console.log('super man constructor');
},
getName: function () {
var name = SuperMan.uber.getName.call(this);
return 'I am ' + name;
}
}
);
169. var SuperMan = klass(
Man,
{
__construct: function (what) {
console.log('super man constructor');
},
getName: function () {
var name = SuperMan.uber.getName.call(this);
return 'I am ' + name;
}
}
);
170. var SuperMan = klass(
Man,
{
__construct: function (what) {
console.log('super man constructor');
},
getName: function () {
var name = SuperMan.uber.getName.call(this);
return 'I am ' + name;
}
}
);
171. var clark = new SuperMan('Clark Kent');
// logs 'man constructor'
// and 'super man constructor'
clark.getName();
// 'I am Clark Kent'
172. var clark = new SuperMan('Clark Kent');
// logs 'man constructor'
// and 'super man constructor'
clark.getName();
// 'I am Clark Kent'
173. var clark = new SuperMan('Clark Kent');
// logs 'man constructor'
// and 'super man constructor'
clark.getName();
// 'I am Clark Kent'
174. var clark = new SuperMan('Clark Kent');
// logs 'man constructor'
// and 'super man constructor'
clark.getName();
// 'I am Clark Kent'
175. var clark = new SuperMan('Clark Kent');
// logs 'man constructor'
// and 'super man constructor'
clark.getName();
// 'I am Clark Kent'
176. var klass = function (Parent, props) {
var Child, F, i;
Child = function () {
if (Child.uber && Child.uber.hasOwnProperty('__construct')) {
Child.uber.__construct.apply(this, arguments);
}
if (Child.prototype.hasOwnProperty('__construct')) {
Child.prototype.__construct.apply(this, arguments);
}
};
Parent = Parent || Object;
F = function () {};
F.prototype = Parent.prototype;
Child.prototype = new F();
Child.uber = Parent.prototype;
Child.prototype.constructor = Child;
for (i in props) {
if (props.hasOwnProperty(i)) {
Child.prototype[i] = props[i];
}
}
return Child;
};
177. var klass = function (Parent, props) {
var Child, F, i;
Child = function () {
if (Child.uber && Child.uber.hasOwnProperty('__construct')) {
Child.uber.__construct.apply(this, arguments);
}
if (Child.prototype.hasOwnProperty('__construct')) {
Child.prototype.__construct.apply(this, arguments);
}
};
Parent = Parent || Object;
F = function () {};
F.prototype = Parent.prototype;
Child.prototype = new F();
Child.uber = Parent.prototype;
Child.prototype.constructor = Child;
for (i in props) {
if (props.hasOwnProperty(i)) {
Child.prototype[i] = props[i];
}
}
return Child;
};
178. var klass = function (Parent, props) {
var Child, F, i;
Child = function () {
if (Child.uber && Child.uber.hasOwnProperty('__construct')) {
Child.uber.__construct.apply(this, arguments);
}
if (Child.prototype.hasOwnProperty('__construct')) {
Child.prototype.__construct.apply(this, arguments);
}
};
Parent = Parent || Object;
F = function () {};
F.prototype = Parent.prototype;
Child.prototype = new F();
Child.uber = Parent.prototype;
Child.prototype.constructor = Child;
for (i in props) {
if (props.hasOwnProperty(i)) {
Child.prototype[i] = props[i];
}
}
return Child;
};
179. var klass = function (Parent, props) {
var Child, F, i;
Child = function () {
if (Child.uber && Child.uber.hasOwnProperty('__construct')) {
Child.uber.__construct.apply(this, arguments);
}
if (Child.prototype.hasOwnProperty('__construct')) {
Child.prototype.__construct.apply(this, arguments);
}
};
Parent = Parent || Object;
F = function () {};
F.prototype = Parent.prototype;
Child.prototype = new F();
Child.uber = Parent.prototype;
Child.prototype.constructor = Child;
for (i in props) {
if (props.hasOwnProperty(i)) {
Child.prototype[i] = props[i];
}
}
return Child;
};
180. var klass = function (Parent, props) {
var Child, F, i;
Child = function () {
if (Child.uber && Child.uber.hasOwnProperty('__construct')) {
Child.uber.__construct.apply(this, arguments);
}
if (Child.prototype.hasOwnProperty('__construct')) {
Child.prototype.__construct.apply(this, arguments);
}
};
Parent = Parent || Object;
F = function () {};
F.prototype = Parent.prototype;
Child.prototype = new F();
Child.uber = Parent.prototype;
Child.prototype.constructor = Child;
for (i in props) {
if (props.hasOwnProperty(i)) {
Child.prototype[i] = props[i];
}
}
return Child;
};
181. Child = function () {
if (Child.uber && Child.uber.hasOwnProperty('__construct')) {
Child.uber.__construct.apply(this, arguments);
}
if (Child.prototype.hasOwnProperty('__construct')) {
Child.prototype.__construct.apply(this, arguments);
}
};
182. Child = function () {
if (Child.uber && Child.uber.hasOwnProperty('__construct')) {
Child.uber.__construct.apply(this, arguments);
}
if (Child.prototype.hasOwnProperty('__construct')) {
Child.prototype.__construct.apply(this, arguments);
}
};
183. Child = function () {
if (Child.uber && Child.uber.hasOwnProperty('__construct')) {
Child.uber.__construct.apply(this, arguments);
}
if (Child.prototype.hasOwnProperty('__construct')) {
Child.prototype.__construct.apply(this, arguments);
}
};
184. Child = function () {
if (Child.uber && Child.uber.hasOwnProperty('__construct')) {
Child.uber.__construct.apply(this, arguments);
}
if (Child.prototype.hasOwnProperty('__construct')) {
Child.prototype.__construct.apply(this, arguments);
}
};
185. Child = function () {
if (Child.uber && Child.uber.hasOwnProperty('__construct')) {
Child.uber.__construct.apply(this, arguments);
}
if (Child.prototype.hasOwnProperty('__construct')) {
Child.prototype.__construct.apply(this, arguments);
}
};
186. Parent = Parent || Object;
F = function () {};
F.prototype = Parent.prototype;
Child.prototype = new F();
Child.uber = Parent.prototype;
Child.prototype.constructor = Child;
187. Parent = Parent || Object;
F = function () {};
F.prototype = Parent.prototype;
Child.prototype = new F();
Child.uber = Parent.prototype;
Child.prototype.constructor = Child;
188. Parent = Parent || Object;
F = function () {};
F.prototype = Parent.prototype;
Child.prototype = new F();
Child.uber = Parent.prototype;
Child.prototype.constructor = Child;
189. Parent = Parent || Object;
F = function () {};
F.prototype = Parent.prototype;
Child.prototype = new F();
Child.uber = Parent.prototype;
Child.prototype.constructor = Child;
190. Parent = Parent || Object;
F = function () {};
F.prototype = Parent.prototype;
Child.prototype = new F();
Child.uber = Parent.prototype;
Child.prototype.constructor = Child;
191. Parent = Parent || Object;
F = function () {};
F.prototype = Parent.prototype;
Child.prototype = new F();
Child.uber = Parent.prototype;
Child.prototype.constructor = Child;
192. var klass = function (Parent, props) {
/* ... */
for (i in props) {
if (props.hasOwnProperty(i)) {
Child.prototype[i] = props[i];
}
}
return Child;
};
193. var klass = function (Parent, props) {
/* ... */
for (i in props) {
if (props.hasOwnProperty(i)) {
Child.prototype[i] = props[i];
}
}
return Child;
};
194. var klass = function (Parent, props) {
/* ... */
for (i in props) {
if (props.hasOwnProperty(i)) {
Child.prototype[i] = props[i];
}
}
return Child;
};
195. var klass = function (Parent, props) {
/* ... */
for (i in props) {
if (props.hasOwnProperty(i)) {
Child.prototype[i] = props[i];
}
}
return Child;
};
196. var klass = function (Parent, props) {
/* ... */
for (i in props) {
if (props.hasOwnProperty(i)) {
Child.prototype[i] = props[i];
}
}
return Child;
};
197. var klass = function (Parent, props) {
/* ... */
for (i in props) {
if (props.hasOwnProperty(i)) {
Child.prototype[i] = props[i];
}
}
return Child;
};
198. var klass = function (Parent, props) {
var Child, F, i;
Child = function () {
if (Child.uber && Child.uber.hasOwnProperty('__construct')) {
Child.uber.__construct.apply(this, arguments);
}
if (Child.prototype.hasOwnProperty('__construct')) {
Child.prototype.__construct.apply(this, arguments);
}
};
Parent = Parent || Object;
F = function () {};
F.prototype = Parent.prototype;
Child.prototype = new F();
Child.uber = Parent.prototype;
Child.prototype.constructor = Child;
for (i in props) {
if (props.hasOwnProperty(i)) {
Child.prototype[i] = props[i];
}
}
return Child;
};