Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

119
Views
Can you store a JS object in a SharedArrayBuffer?

I need to share an object between a client side application and a web worker and I heard about SharedArrayBuffers. This is what I'd like to do.

main.js

let myWorker = new Worker('/worker.js')
let mySab = new SharedArrayBuffer(1024)
let myObj = { foo: 'bar', bar: 'foo' }
// Save 'myObj' to 'mySab'
worker.postMessage(sab)

worker.js

self.onmessage = (e) => {
    let myObj = BLANK // Get 'myObj' from SharedArrayBuffer
}

Is this possible? The examples I've seen of ShareArrayBuffers only ever save numbers in the buffer. Any help is appreciated!

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

No, SharedArrayBuffers only store binary data. You can only send copies of objects via the built-in postMessage function.

Sources:

https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/SharedArrayBuffer

https://developer.mozilla.org/en-US/docs/Web/API/Web_Workers_API/Using_web_workers

about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!