11
r6586
7y

My CTO uses an array instead of objectto keep list of items with random numerical keys. I told him you’re creating multiple unintended undefined members in between, he said: yeah that’s how silly JavaScript is :-|

Comments
  • 0
    Really? Can you share a link of the documentation?
    Or does it depend on the runtime environment?
    Would be interested in this :)
  • 3
    No need for docs, try
    const arr =[]; const key1=5; const key2=10;
    arr[key1]=10;
    arr[key2]=20;
    console.log(arr.length);

    Do you expect 2?
Add Comment