Say we have two functions, that return a large object. One returns data directly, the other assigns it to an inner variable and returns this variable. Does anybody have an idea if there would be a difference in the heap memory that would be allocated as well as in performance and why? Is the browser engine going to optimize somehow the code, so it might end up being the same?
function foo() {
return getSmth();
}
function foo() {
var bar = getSmth();
return bar;
}