The Atomics.load method returns the value inside a typed array at a particular index value. Here's how to use it:
const sab = new SharedArrayBuffer(1);const arr = new Uint8Array(sab);arr[0] = 5;console.log(Atomics.load(arr, 0));
The preceding code is just a thread-safe way to access arr[0].
This outputs:
5