Memory Management?

Hey fusers, in JS, do we need to “unallocate” a var when we’re done using it?
e.g.

  var something = 1234; 
  var somethingElse = 4321;
  var somethingMore = 100;
  var result = 0;
  switch (input) {
    case 1: result = input + something;
      break;
    case 2: result = input + something + somethingElse;
      break;
  }
  result *= 0.15 + somethingMore;

  //unallocate
  something = null;
  somethingElse = null;
  somethingMore = null;

  return result;
}

I don’t think it’s necessary inside a function because garbage collection deals with them.

1 Like

Humm, the following scientific article definitely will help you :wink:
https://moduscreate.com/blog/dynamic-memory-and-v8-with-javascript/

1 Like