Created
          May 29, 2022 05:52 
        
      - 
      
 - 
        
Save takidog/a0cbc81a8b313f22166c39b0f5246dbc to your computer and use it in GitHub Desktop.  
    localStorage backup, recover
  
        
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | var result = []; | |
| Object.keys(localStorage).forEach(function(key){ | |
| result.push({"name":key,"value":localStorage.getItem(key)}); | |
| }); | |
| console.log(JSON.stringify(result)); | 
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | let recover = ; // paste result on here, without add any ' ". | |
| for (let item of recover){ | |
| localStorage.setItem(item['name'],item['value']); | |
| } | 
  
    Sign up for free
    to join this conversation on GitHub.
    Already have an account?
    Sign in to comment