-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathstorage.js
More file actions
38 lines (31 loc) · 786 Bytes
/
storage.js
File metadata and controls
38 lines (31 loc) · 786 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
function store(){
var name = 'samir'
localStorage.setItem("name",name)
localStorage.setItem("id",101)
var user = {
name : 'ram',
id : 102
}
struser = JSON.stringify(user)
localStorage.setItem("user",struser)
alert("data stored")
}
function retrieve(){
var name = localStorage.getItem("name")
var id = localStorage.getItem("id")
var user = localStorage.getItem("user")
var objUser = JSON.parse(user)
console.log(name)
console.log(id)
console.log(user)
console.log(objUser)
console.log(objUser.name)
}
function remove(){
localStorage.removeItem("id")
alert("id removed")
}
function cleardata(){
localStorage.clear()
alert("all data removed")
}