JS%20Class%20-%205
JS%20Class%20-%205
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.
3. Local Storage
It allows web applications to store data locally within the user's browser.
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
gender Male
city Delhi
setItem()
getItem()
clear()
removeItem()
Syntax: localStorage.getItem("Key");
Try out the setItem() and getItem() methods in the below Code
//HTML CODE
<body>
Your HTML code goes here. Write JavaScript code in JAVASCRIPT tab.
</body>
//JS CODE
localStorage.setItem("fullName", "Rahul Attuluri");
localStorage.setItem("gender", "Male");
localStorage.setItem("city", "Delhi");
console.log(fullName);
console.log(gender);
console.log(city);
4. Values
4.1 null
We use null in a situation where we intentionally want a variable but don't need a value to it.
//JS CODE
let selectedColor = null;
console.log(selectedColor); // null
console.log(typeof(selectedColor)); // object
5. HTML Elements
5.1 The textarea Element
The HTML textarea element can be used to write the multiline text as an input.
//HTML CODE
<body>
<textarea rows="8" cols="55" id="message"></textarea>
<br />
<button class="btn btn-primary mt-1" id="saveButton">Save</button>
</body>
In this assignment, let's build a Movie Reviews page by applying the concepts we learned till now.
o If the value of the HTML input element with the id titleInput is not empty,
Note
Try to achieve the design as close as possible.
Achieve the design with HTML, CSS, and functionality with JS.
Resources
#2d3a35
#7b8794
#cbd2d9
2.Click Counter
In this assignment, let's build a Click Counter by applying the concepts we learned till now.
Note
Try to achieve the design as close as possible.
Achieve the design with HTML, CSS and functionality with JS.
Resources
#f1f5f8
#2d3a35
#c20a72
Roboto