code hindi Information technologyCareer blogs Courses info Digital Marketing About

HTML Web Storage API kya hai? kya hai? HTML Web Storage API explained in Hindi

HTML Web Storage API ek set of APIs hai jo modern web browsers mein available hai aur client-side storage ko handle karne ke liye use hota hai. Iska istemal web applications mein data ko temporary ya permanent storage ke liye hota hai, taaki application ke data ko user ke browser mein store karke rakh sakein.

HTML Web Storage API ke do pramukh components hote hain:

  • 1. localStorage : Ye ek key-value pair based storage mechanism provide karta hai jisse aap web pages ke data ko store kar sakte hain. Ye data user ke browser mein permanent storage ke roop mein save hota hai, aur jab tak user manually clear nahi karta hai, tab tak wo data persist rehta hai.
  • 2. sessionStorage : Ye bhi localStorage ki tarah ek key-value pair based storage mechanism hai, lekin ismein data temporary hota hai aur user ke session ke saath hi expire ho jata hai. Iska matlab hai ki jab user browser tab ya window ko close karta hai, tab sessionStorage mein stored data bhi delete ho jata hai.

Dono hi storage mechanisms ko JavaScript ke through access kiya ja sakta hai. Inka istemal user preferences, user session data, temporary data storage, offline data caching, aur application state management ke liye hota hai.

Example:

// Storing data in localStorage localStorage.setItem('username', 'John');

// Retrieving data from localStorage var username = localStorage.getItem('username'); console.log(username); // Output: John

// Storing data in sessionStorage sessionStorage.setItem('isLoggedIn', true);

// Retrieving data from sessionStorage var isLoggedIn = sessionStorage.getItem('isLoggedIn'); console.log(isLoggedIn); // Output: true

HTML Web Storage API ka istemal web applications mein client-side data storage ke liye hota hai, jo user experience ko improve karta hai aur web applications ko robust banata hai.

Server kya hota hai

Integrated Development Environment (IDE) kya hai