2

Есть массив объектов var users = [{name: ‘Alex’, age: 20}, {name: ‘Oleg’, age: 30}];

Как сохранить users в localStorage?

1 ответ 1

6
localStorage.setItem('storedUsers', JSON.stringify(users));
...
var users = [];
if (localStorage.getItem('storedUsers'))
  users = JSON.parse(localStorage.getItem('storedUsers'));
1
  • Спасибо, попробую!
    – Marina
    13 фев 2020 в 18:47

Ваш ответ

By clicking “Отправить ответ”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Всё ещё ищете ответ? Посмотрите другие вопросы с метками или задайте свой вопрос.