JavaScript uses automatic garbage collection. The collector uses a mark-and-sweep algorithm: starting from roots (global object, the current call stack), it marks everything reachable, then frees everything unreachable. You never free() manually — but you can accidentally keep references alive, causing leaks.
The four classic leak sources
. = . || {};
.[id] = bigObject;
el.(, handler);
id = (tick, );
() {
huge = ();
huge.;
}
