0

For example, will this data variable be garbage collected instantly?

{
  const data = new Array(10000);
}

...and if so, does this mean using scope-blocks in JavaScript can be a practical method of localizing short-lived data? I know this shouldn't be high priority or anything, but I'm just curious.

  • JavaScript garbage collection is controlled by the runtime engine (not the JS code). While some engines might allow you to configure behavior ahead of runtime, that's not standardized. – jsejcksn Jan 03 '23 at 07:10
  • Does this answer your question? [Can I trigger JavaScript's garbage collection?](https://stackoverflow.com/questions/8032928/can-i-trigger-javascripts-garbage-collection) – jsejcksn Jan 03 '23 at 07:10

0 Answers0