Skip to main content
Journey Uncommon Logo
JourneyUncommon
hardJavaScriptSharedArrayBuffer and AtomicsSingle-choice MCQ

Atomics.compareExchange is called when the expected value does not match the current value. What is returned and what happens to memory?

const sab = new SharedArrayBuffer(8); const i32 = new Int32Array(sab); i32[0] = 7; const r = Atomics.compareExchange(i32, 0, 999, 42); console.log(r, i32[0]);