1. Execution Context
The environment in which JavaScript Code runs is called Execution Context.
Execution context contains all the variables, objects, and functions.
Execution Context is destroyed and recreated whenever we reload an Application.
2. Storage Mechanisms
2.1 Client-Side Data Storage
Client-Side Data Storage is storing the data on the client (user's machine).
- Local Storage
- Session Storage
- Cookies
- IndexedDB and many more.
2.2 Server-Side Data Storage
Server-Side Data Storage is storing the data on the server.
3. Local Storage
It allows web applications to store data locally within the user's browser.
It is a Storage Object. Data can be stored in the form of key-value pairs.
Please note that both key and value must be strings. If their type is other than a string, they get converted to strings automatically.
Key | Value |
---|---|
fullName | Rahul Attuluri |
gender | Male |
city | Delhi |
To access and work with Local Storage we have below methods:
- setItem()
- getItem()
- clear()
- removeItem()
3.1 The setItem() Method
The
Syntax:
3.2 The getItem() Method
The
Syntax:
Try out the
4. Values
4.1 null
We use
5. HTML Elements
5.1 The textarea Element
The HTML
- The HTML rowsattribute specifies the number of lines.
- The HTML colsattribute specifies the number of characters per each line.
Try out the HTML
1.1 The removeItem() Method
The
Syntax:
Key - Name of the key to be removed
Try out persisting the todo checked status in the below Code Playground.