S
S
Stepan2020-05-13 00:54:28
JavaScript
Stepan, 2020-05-13 00:54:28

How to copy local storage?

How to copy everything that is in local storage? To then transfer to another browser

Answer the question

In order to leave comments, you need to log in

1 answer(s)
H
hzzzzl, 2020-05-13
@Stepashka20

storage = {...localStorage}

...
// перенести объект JSON.stringify(storage) в другой браузер
...

for (const[key, val] of Object.entries( JSON.parse(storage) )) {
  localStorage.setItem(key, val)
}

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question