Skip to content

Latest commit

 

History

History
26 lines (15 loc) · 1.54 KB

201-class13.md

File metadata and controls

26 lines (15 loc) · 1.54 KB

Class 201.13

Notes

  • POJO: Plain Old Javascript Object

Readings

Q&A's

  1. Why would a developer use local storage for a web application?

A developer would use local storage for a web application to store data client-side and persist state between sessions. This allows the app to remember user choices, preferences, form data etc. without needing a server round-trip. Local storage provides a performance boost and offline capability.

  1. What information should not be stored in local storage?

Sensitive user information like passwords, financial data, personal details etc. should not be stored in local storage. Since it is client-side only, local storage data could be accessible by malicious code injected into a page. Local storage should only contain non-critical data related to app state.

  1. Local storage can store what type of data? How would you convert it to that type before storing?

Local storage can only directly store string data. To store other data types like objects, arrays, etc. you need to convert them to strings before storing. This can be done using JSON.stringify() to convert the data to a JSON string that can then be saved in local storage. When needed, JSON.parse() can convert that string back into the original JavaScript object.

References

  • Google Bard and ChatGPT