Нашёл неплохую статью с подробным объяснением того, как JS работает с памятью
TL;DR:
All JavaScript values are allocated on the heap accessed by pointers no matter if they are objects, arrays, strings or numbers (except for small integers i.e. smi in V8 due to pointer tagging).
The stack only stores temporary, function-local and small variables (mostly pointers) and that's largely unrelated to JavaScript types.
https://www.zhenghao.io/posts/javascript-memory
TL;DR:
All JavaScript values are allocated on the heap accessed by pointers no matter if they are objects, arrays, strings or numbers (except for small integers i.e. smi in V8 due to pointer tagging).
The stack only stores temporary, function-local and small variables (mostly pointers) and that's largely unrelated to JavaScript types.
https://www.zhenghao.io/posts/javascript-memory