4 ms·
Weak maps offer better performance in some cases and reduce code complexity though. Cleaning up your maps approximates the same outcome but requires more logic
by steve_adams_86 2y ago
Weak 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.