The value stored in num is the number of key-value pairs currently stored in localStorage. The localStorage object implements the Web Storage Storage interface, which stores data as named string key/value entries for the current origin. Its length property is read-only and returns the number of data items stored in that Storage object, not the size of the stored data and not the remaining capacity. MDN’s Storage reference explicitly defines length as returning the number of data items stored, and its example shows that after three items are added to localStorage, localStorage.length returns 3. Therefore, if the storage area contains five named entries, num receives 5; if it contains no entries, num receives 0. Option A is incorrect because available bytes are not exposed through length. Option B is unrelated to Web Storage. Option C is incorrect because browser storage quota or capacity is separate from the length property. References/topics: Web Storage API, localStorage, Storage.length, key-value storage, application state.
==========
Contribute your Thoughts:
Chosen Answer:
This is a voting comment (?). You can switch to a simple comment. It is better to Upvote an existing comment if you don't have anything to add.
Submit