var students = [
{
id: 'st01',
name: 'Name 1',
age: 20
},
{
id: 'st02',
name: 'Name 2',
age: 21
},
{
id: 'st03',
name: 'Name 3',
age: 22
}
];
localStorage.setItem('students', JSON.stringify(students));
var studentInfos = JSON.parse(localStorage.getItem('students'));
console.log('Student List');
for (var i = 0; i < studentInfos.length; i++) {
console.log('id: ' + studentInfos[i].id);
console.log('name: ' + studentInfos[i].name);
console.log('age: ' + studentInfos[i].age);
console.log('-------------------');
}
Student List
id: st01
name: Name 1
age: 20
-------------------
id: st02
name: Name 2
age: 21
-------------------
id: st03
name: Name 3
age: 22
-------------------