I've noticed that some developers prefer using code that looks like
const STUFF_MAP = Object.create(null);
It seems that STUFF_MAP
is intended to be used like a map, hence the choice of using Object.create(null)
over {}
(to avoid conflicts with properties). However, I'm curious if there are any benefits to simply using
const STUFF_MAP = new Map();
Can you please explain when it's appropriate to use each method? Could it be related to compatibility issues with pre-ES6 environments?