+ 4
JavaScript Garbage Collector
Here's a somewhat difficult question. Let's say I declare an array as follows: var arr = [1, 2, 3]; and I set the length of the array to 2 as follows: arr.length = 2; Would the garbage collector remove the third element from memory? Does anyone know the answer?
2 Réponses
+ 6
Yes it will. arr will then be [1, 2]. You can test it in the Code Playground.