skip to Main Content

Can localStorage API(getItem/setItem) be used with Javascript’s setTimeout?

I am so curious why these two codes behave differently? Functions like 'console.log' would work in both ways, while localStorage API functions(getItem,setItem) does not work. setTimeout(()=>localStorage.setItem('1','2'),1000) // setTimeout(code, delay) works setTimeout(localStorage.setItem,1000,'1','2') // setTimeout(functionRef, delay, param1) not working, error "Uncaught TypeError:…

VIEW QUESTION
Back To Top
Search