-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathwebStorage.js
More file actions
39 lines (29 loc) · 878 Bytes
/
webStorage.js
File metadata and controls
39 lines (29 loc) · 878 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
// *web storage api
// window.alert("hello")
// alert("ok")
// window.alert(window.location)
// alert(location)
//storage
const myArray = ["eat", "sleep", "code"];
const myObject = {
name: "Amir",
age: 22,
hobbies: ["eat", "sleep", "code"],
logName: function () {
console.log(this.name);
}
}
// myObject.logName()
// ?session storage
// sessionStorage.setItem("mySessionStore", JSON.stringify(myArray));
// const mySessionData = JSON.parse(sessionStorage.getItem("mySessionStore"));
// console.log(mySessionData);
// ?local storage
localStorage.setItem("myLocalStore", JSON.stringify(myArray));
// localStorage.removeItem("myLocalStore")
// localStorage.clear()
const key = localStorage.key(0)
const length = localStorage.length
const myLocalData = JSON.parse(sessionStorage.getItem("myLocalStore"));
console.log(key);
console.log(length);