3 ms·
Just don't use weakmaps. Clean up your maps instead.
by jongjong 2y ago
Just don't use weakmaps. Clean up your maps instead.
- steve_adams_86 2y agoWeak maps offer better performance in some cases and reduce code complexity though. Cleaning up your maps approximates the same outcome but requires more logic to do it at no benefit to your application. Weak maps also have the benefit of explicitly showing how the data is meant to be managed; they have a distinct purpose. Regular maps are far more versatile, but this versatility doesn’t benefit use cases a weak map is suited to.