JavaScript engines employ garbage collection techniques like “mark-and-sweep” and reference counting. The “mark-and-sweep” process goes through live objects (marked) and separates them from unreachable ones (sweep), clearing memory used by those objects. This process happens in the background, helping to optimize application performance and memory usage.