compareExchangebeginnerconst i32 = new Int32Array(new SharedArrayBuffer(4))
Atomics.store(i32, 0, 5)
Atomics.compareExchange(i32, 0, 5, 10) // β 5 (old val)
Atomics.load(i32, 0) // β 10compareExchange() updates a value only if it currently equals the expected value.
Use Atomics.compareExchange to get the old value at an index before exchanging.