获取全部storage.js 457 B

12345678910111213
  1. const localStorageEntries = Object.entries(localStorage);
  2. const sessionStorageEntries = Object.entries(sessionStorage);
  3. console.log("localStorage entries:", JSON.stringify(localStorageEntries));
  4. console.log("sessionStorage entries:", JSON.stringify(sessionStorageEntries));
  5. localStorageEntries.forEach(([key, value]) => {
  6. localStorage.setItem(key, value);
  7. });
  8. sessionStorageEntries.forEach(([key, value]) => {
  9. sessionStorage.setItem(key, value);
  10. });