Assuming that both your keys and your values are serialisable,
localStorage.myMap = JSON.stringify(Array.from(map.entries()));
should work. For the reverse, use
map = new Map(JSON.parse(localStorage.myMap));
More Related Contents:
- How do you JSON.stringify an ES6 Map?
- Map vs Object in JavaScript
- Using Array objects as key for ES6 Map
- How to reliably check an object is an EcmaScript 6 Map/Set?
- Define a custom hash() method for use with ES6 maps
- JavaScript – Map() increment value
- JSON stringify a Set
- map function not working in React
- First item from a Map on JavaScript ES2015
- What is the “right” JSON date format?
- Javascript object literal: what exactly is {a, b, c}?
- ES6 Modules: Undefined onclick function after import
- Performance of key lookup in JavaScript object
- Javascript ES6 TypeError: Class constructor Client cannot be invoked without ‘new’
- jQuery returning “parsererror” for ajax request
- Why do I need to await an async function when it is not supposedly returning a Promise?
- Concatenate two JSON objects
- Scope of Default function parameters in javascript
- How to use CORS to implement JavaScript Google Places API request
- Filtering an array with a function that returns a promise
- jQuery JSON to string?
- comparing ECMA6 sets for equality
- How to escape a JSON string to have it in a URL?
- JSON security best practices?
- How can I get a list of the differences between two JavaScript object graphs?
- How to deterministically verify that a JSON object hasn’t been modified?
- How to namespace es6 classes (for React components)
- How to send data from HTML form to Google Spreadsheet using JavaScript?
- Return object with default values from an array in JavaScript
- Deep nested array of objects not rendering