How to get the array from localStorage?

For example:
1. Put this array in localStorage
$arr = {
 'id': id,
 'title': title,
 'url': link,
 };

2.Get content localSotrage
And how then to be? Separately to the data obtained? (Example: $arr['title'])
June 10th 19 at 14:50
2 answers
June 10th 19 at 14:52
Solution
const id = 1
const title = 'title'
const link = 'https://toster.ru/q/488804'
const $arr = {
 'id': id,
 'title': title,
 'url': link,
}

window.localStorage.setItem('arr', JSON.stringify($arr))

const array = JSON.parse(window.localStorage.getItem('arr'))

console.log(array['title'])
June 10th 19 at 14:54
Solution
var myObject = {id: 1, title: 'title', url: 'link'};
localStorage.setItem('myObject', JSON.stringify(myObject));
...
myObject = JSON.parse(localStorage.getItem('myObject'));
if (null !== myObject) {
console.log(myObject.title);
}

Find more questions by tags HTML