A user sets a post filter preference in the Blog application using this code:
localStorage.setItem('prefs', 'tag:tech');
They close their browser and return three days later. What happens when the app tries to read localStorage.getItem('prefs')?
localStorage.getItem('prefs')
It returns nothing because the server didn’t sync it.
It fails because local storage can’t store strings.
It returns 'tag:tech' because local storage persists until cleared.
'tag:tech'
It returns null because local storage expires after a day.
null
An admin starts writing a post in the Blog app and saves it as a temporary draft:
sessionStorage.setItem('draft', 'My awesome post...');
What happens to this draft in these scenarios? (Select all that apply.)
The server can read it to save the draft permanently.
It’s gone if the admin closes the original tab.
It’s available in a new tab opened in the same browser.
It persists if the browser crashes and the tab is restored.
The Blog app uses IndexedDB to store multiple drafts with this setup:
const dbPromise = indexedDB.open('BlogDrafts', 1); dbPromise.onupgradeneeded = (event) => { event.target.result.createObjectStore('drafts', { keyPath: 'id' }); }; dbPromise.onsuccess = (event) => { const db = event.target.result; const tx = db.transaction('drafts', 'readwrite'); tx.objectStore('drafts').add({ id: 1, text: 'Draft 1...' }); };
An admin saves a draft with id: 1. What’s true about this storage? (Select all that apply.)
id: 1
It can store more drafts than local storage’s 5-10MB limit.
It’s erased when the tab closes, like session storage.
It allows searching drafts by id or other fields if indexed.
id
It’s automatically sent to the server for backup.
In the Blog app, a developer considers storing a user’s password in local storage with:
localStorage.setItem('password', 'secret123');
Why might this be risky? (Select all that apply.)
JavaScript running on the page could read it.
The server might reject it due to size limits.
It’s sent to the server with every request, risking exposure.
It stays on the device forever unless cleared.
Compare these storage options in the Blog app:
session_id=abc789xyz
prefs=tag:tech
draft=My awesome post...
Session storage has a smaller size limit than cookies.
Cookies are the only option that syncs with the server.
All three can store sensitive data securely with proper settings.
Local storage and session storage both expire after 24 hours.
An admin wants to save multiple drafts offline in the Blog app. The developer chooses IndexedDB over cookies. Why is this a better choice? (Select all that apply.)
IndexedDB automatically secures data against JavaScript access.
IndexedDB can handle more data than cookies’ 4KB limit.
IndexedDB syncs with the server more efficiently than cookies.
IndexedDB supports structured data like objects, not just strings.
This content is only available to registered users.Please register at the the home page.