[js] if there is no variable to receive the return value of map, where will the return value of map be put?

In a case like this, where will the return value of the map function be put? Is it also saved in memory?
arr.map (item= > {

)
return item*2

})

Mar.29,2021

will get the value of the expression. If there is no reference, there will be garbage collection


return value, but you can't find it. After execution, it will be treated as garbage collection directly. It won't be saved.


returned values are not garbage collected, only overwritten. Function return values are usually stored in specific registers, for example, return value types less than 32 bits will be stored in eax, even if you do not use it, the return value will still be in eax, and this value will not be recovered, but other subsequent operations may use eax to store new values, and the return value of the last function will be overwritten. This is not a garbage collection mechanism!

Menu