# prefer-map-from-entries 📝 Prefer `new Map()` over `Object.fromEntries()` when using the result as a map. 💼 This rule is enabled in the following [configs](https://github.com/sindresorhus/eslint-plugin-unicorn#recommended-config): ✅ `recommended`, ☑️ `unopinionated`. 🔧 This rule is automatically fixable by the [`--fix` CLI option](https://eslint.org/docs/latest/user-guide/command-line-interface#--fix). Use a [`Map`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Map) when a value created from `Object.entries()` or known non-array-index string-keyed entry pairs is only used through map-like operations. This rule only reports variables where the initializer and all references can be converted together. Unsupported references and unknown entry shapes are ignored instead of partially converting the variable. Array-index keys are ignored because object key ordering does not always match `Map` iteration semantics. ## Examples ```js // ❌ const object = Object.fromEntries(Object.entries(source)); if (Object.hasOwn(object, 'foo')) { console.log(object.foo); } ``` ```js // ✅ const object = new Map(Object.entries(source)); if (object.has('foo')) { console.log(object.get('foo')); } ``` ```js // ✅ const object = Object.fromEntries(entries); foo(object); ```