Is there a difference between returning an internal variable from a function compared to returning the value directly

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;
}
+4
source share
1 answer

. , , . , , . / , - , .

, javascript .

+3

Source: https://habr.com/ru/post/1610371/


All Articles