1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33
|
function toto(a, b) {
this.a = a;
this.b = b;
if( typeof toto.initialized == "undefined" ) {
toto.prototype.describe = function() {
console.log(this.a + ' / ' + this.b);
}
toto.initialized = true;
}
}
function totoManager() {
this.totos = new Array();
if( typeof totoManager.initialized == "undefined" ) {
totoManager.prototype.fullInfo = function() {
for (var i = 0; i < this.totos.length; i++) {
this.totos[i].describe();
}
}
toto.initialized = true;
}
}
var tab = new totoManager();
tab.totos.push(new toto(1,2));
tab.totos.push(new toto(3,4));
tab.totos.push(new toto(5,6));
tab.fullInfo(); |
Partager