[Solved] get all item in local storage


some small confusing parts in your example.

  1. You can use the keyname “buy user_film” but i will not recommended. Because you may have some problems with it later. (e.g. dynamic key names.)

key: buy user_film{[“”The Silence of the Lambs””,””fats and
furiuos””]}

You can have objects inside an array but not vice versa

3.

film=JSON.parse(JSON.stringify(localStorage.getItem(“buy
user_film”)));

first you stringify and step later parse to an object. that makes no sense here right now.

4.

var value = localStorage[i];

I didn’t quite understand this part. That makes noc sense to iterate the storage by the length of the film array?
Maybe: you expect in the lcoalstorage an item with the name “The Silence of the Lambs”? than i suggest that you need condition like if(localStorage.has(film[i]))) {…}.

Noote: You mean: “fast and furious”

try this:

var obj = JSON.parse(localStorage.getItem("buy user_film"));
var pos = obj.length;
var i;
for(i=0;i<pos; i++){
  console.log(obj[i]);
}

2

solved get all item in local storage