Questions on DOM and BOM

  1. What is DOM and BOM? What is difference between them?
  2. How to store and retrieve data from local storage?
  3. What is difference between localStorage and sessionStorage?

Dom: object is that have to do with currently loaded page

Bom: object that deal with everything outside of the page

1 Like
  1. DOM- Document object model , BOM- Browser Object model. DOM deals with objects in the document whereas BOM deals with objects in the browser window.
  2. store data- localstorage.setItem() , Retrieve data- localstorage.getItem() , document.cookie
  3. Data in Local storage doesn’t expire but data in session storage expires when the page session ends.
1 Like

1.The DOM(Direct Object Model) is focused on representing the structure and content of a web page, while the BOM(Browser Object Model) is focused on interacting with the browser itself.
2. To store data in local storage, you use the localStorage.setItem(key, value) method and To retrieve data from local storage, you use the localStorage.getItem(key) method,
3. Data stored in localStorage is persistent and remains available even after the browser is closed and reopened and Data stored in sessionStorage is only available for the duration of a page session.

1 Like
  1. To retrieve data, you use the getItem() function. This takes a single parameter; the key that you used when storing data. var name = localStorage. getItems

  2. Both of them can be accessed by client side only and server doesn’t have access and thus eliminate the security threat cookies present. The difference between localStorage and sessionStorage is that sessionStorage is lost the moment the browser is closed, while localStorage remain till the browser cache is cleared

1 Like

The different between session storage local storage,while data in local storage dosent expire data in session storage is cleared when the page session ends.

1 Like