Here, I have this two code :
var mod = function() {
var a = function() {
this.fucname = 'hello';
};
a.prototype.build = function() {
return 'before '+this.fucname;
};
return new a();
};
for( var i=0; i<10000; i++ ){
var newfuc = mod();
};
and
var a = function() {
this.fucname = 'hello';
};
a.prototype.build = function() {
return 'before '+this.fucname;
};
for( var i=0; i<10000; i++ ){
var newfuc = new a();
};
After I check both in chrome dev, the second code take a JS HEAP 3.0MB, the first code take a JS HEAP 10MB.
Is that mean, the build function has been created 10000 time in the first code? and how can I refine it without remove the cover mod
?
I have to pass something into the function...