1function set(){
2 var sendJSON = JSON.stringify(allMovie);
3 localStorage.setItem('allMovie',sendJSON)
4}
5
6function get(){
7 var getJSON = localStorage.getItem('allMovie');
8 if (getJSON){
9 allMovie = JSON.parse(getJSON)
10 }
11
12}
1//localStorage is an object, so values are stored by key name
2//data from localStorage is always stored in strings
3//usually the values at each key are stringified objects in JSON format, therefore we must parse them
4var data = JSON.parse(localStorage.getItem("key name"));//make sure the "key name" exists in the localStorage