Exam4Training

Which code statement below correctly persists an objects in local Storage?

Which code statement below correctly persists an objects in local Storage?

A . const setLocalStorage = (storageKey, jsObject) => {window.localStorage.setItem(storageKey, JSON.stringify(jsObject));}
B . const setLocalStorage = (jsObject) => {window.localStorage.connectObject(jsObject));}
C . const setLocalStorage= (jsObject) => {window.localStorage.setItem(jsObject);}
D . const setLocalStorage = (storageKey, jsObject) => {window.localStorage.persist(storageKey, jsObject);}

Answer: A

Exit mobile version