How are anonymous objects garbage collected in Javascript?
garbage-collection, javascript, memory-management
Solution
If nobody in scope is referencing the anonymous objects, they'll get garbage collected the next time the GC runs.
So, after Console.info finishes running, they're up for garbage collecting. If you set any in-scope variables to refer to them, then they won't.
Problem
If I create an object without assigning it to anything, when will Javascript garbage collect this object? Here is an example: ``` alert(new Date().getTime()); ``` If no such garbage collection is done, will this cause a memory leak? ``` for (var i = 0; i < 99999999; i++) { console.info(new Date().getTime()); } ```