JSFiddle - React, Tailwind, and code Playground
JavaScript
var fc = {
getName : function() { return this.name; },
setName : function(n) { this.name = n; }
}
function Animal(){}
Animal.init = function(this_){
this_.name = "toto"
this_.getName = fc.getName;
this_.setName = fc.setName;
}
function Loup(){
Animal.init(this);
}
//Test 1
var c = 1000000;
var loups = [];
var j;
for (j = 0; j < c; j++) {
loups[j] = new Loup();
}
var tstart = 0;
var tend = 0;
tstart = new Date().getTime();
for (j = 0; j < c; j++) {
loups[j].setName("tata");
loups[j].getName();
}
if(j=1000000) tend = new Date().getTime() - tstart;
document.write("tempo " + tend / 1000.0 + " seconds<br/>")