javascript - Which one of these two classes requires more memory and why? -
which 1 of these 2 classes requires more memory , why?
function classa() { var inc = 1; this.method = function (b) { return b + inc; } } function classb() { var inc = 1; this.method = function (b) { return b + 1; } }
it's impossible tell, depends on javascript environment you're using lot of other factors.
in v8 example, first 1 require creating closure , need more memory, might change tomorrow or next month. might different in other engines.
worth mentioning, please not perform premature optimization. root of evil in cases. there tight spots such optimization beneficial there lot of lower bearing fruit reap first.
Comments
Post a Comment