Using the Atomics.load(typedArray, index) method

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
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
13.59.191.124