Can a WebWorker access the localStorage?

 Posted by vishalneeraj-24503 on 9/1/2014 | Category: HTML 5 Interview questions | Views: 2656 | Points: 40

No, localStorage and sessionStorage are both undefined in a webworker process.
You would have to call postMessage() back to the Worker's originating code, and have that code store the data in localStorage.
Interestingly, a webworker can use an AJAX call to send/retrieve info to/from a server, so that may open possibilities, depending on what you're trying to do.

Asked In: Many Interviews | Alert Moderator 

Comments or Responses

Login to post response