Let's say we have two functions that return a large object. One returns data directly, another assigns it to an internal variable and returns this variable. Does anyone have an idea if there will be a difference in the heap of memory to be allocated, as well as in performance, and why? Is the browser engine somehow optimizing the code, so it might turn out to be the same?
function foo() {
return getSmth();
}
function foo() {
var bar = getSmth();
return bar;
}
source
share