Consider JavaScript code below. I am creating array of let's say 4 elements and then immediately delete reference to it. When will garbage collection happen? I know it is specific to language implementation, but we have not that many JavaScript engines.
Edit: it is the simplest possible case, but it interests me because garbage collection causes audible glitches in some web audio applications.
var a = [1, 2, 3, 4];
a = null;
// other code
Update: Javascript and Garbage collection does not explain the sequence of events and how it is triggered. I don't want to control garbage collection. I need better understanding to design better code.