0

I am currently javascript developer coming from java, but advancing my knowlendge in data structures & algorithms, so in Java, C, or C++, while declaring array we need to assume its length first like so:

int[] sampleArray = new int[6];

and there are 24 bytes of memory consumed by this array, and we need this because after 24 bytes, there may be some other data type consuming following x bytes. but in javascript we do not need to set the length, and how javascript determines how much memory array will consume?

iLiA
  • 3,053
  • 4
  • 23
  • 45
  • In JavaScript, an array is dynamic in size and can be sparse. This question will probably lead you to a better understanding: https://stackoverflow.com/questions/365975/how-are-javascript-arrays-implemented – spender Nov 28 '19 at 15:09
  • https://stackoverflow.com/questions/20321047/how-are-javascript-arrays-represented-in-physical-memory – KooiInc Nov 28 '19 at 15:21
  • so to be sure, javascript uses Dynamic Memory Allocation right? – iLiA Nov 28 '19 at 15:40

0 Answers0