Atomics.store(typedArray, index, value) writes value into the element at index as one atomic step and returns the value it wrote. Every thread that later reads the slot with Atomics.load() sees either the old value or your complete new value, never a half-written mix. Atomic writes are also ordered: writes you made before the store are visible to a thread that sees the store. That is why the usual pattern is “write the data first, then store the ready flag last”.
Remember
Atomics.store(typedArray, index, value) -> value (as an integer)
Atomics.store(nums, 0, 7) -> 7, nums[0] is 7
Atomics.store(bytes, 0, 300) -> 300, bytes[0] is 44
Atomics.store(bytes, 0, 3.7) -> 3, bytes[0] is 3
write data first, store the flag last
Syntax
store() takes the array, the position, and the value to write.
JavaScript
Atomics.store(typedArray, index, value)
Call
What it does
Atomics.store(typedArray, index, value)
Writes value into typedArray[index] in one atomic step and returns the value as an integer (before any wrap-around).
Atomics.store(bigArray, index, 5n)
For BigInt64Array and BigUint64Array the value must be a BigInt, and the BigInt is returned.
Available since ES2017. Unlike the other writing methods, store() does not return the old value; use Atomics.exchange() if you need it.
Library declarations
JavaScript
Atomics.store(typedArray, index, value) // returns the value (integer)
// typedArray: integer typed arrays only (Int8 ... BigUint64)
// value: converted to an integer; the element keeps the
// wrapped result, the return value is not wrapped
Parameters
Parameter
Description
typedArray
Required. Any integer typed array (Int8Array, Uint8Array, Int16Array, Uint16Array, Int32Array, Uint32Array, BigInt64Array, BigUint64Array), shared or not. Float arrays throw a TypeError.
index
Required. The position to write. It must be from 0 to length - 1; otherwise a RangeError is thrown and nothing is written.
value
Required. The number to write. Fractions are cut off toward zero (3.7 becomes 3). For the BigInt arrays it must be a BigInt.
Return Value
Return Value
Description
Number or BigInt
The value you passed, converted to an integer. It is not wrapped to the element type, so it can differ from what the element now holds.
JavaScript Examples
Example 1 — Write a Status Code
A status slot uses 0 for idle and 2 for finished. store() writes the code and hands back what you wrote.
JavaScript
const status = new Int32Array(1);
console.log(Atomics.store(status, 0, 2)); // 2
console.log(Atomics.load(status, 0)); // 2
console.log(Atomics.store(status, 0, 0)); // 0
The reader checks the flag first. While slot 0 is 0 it returns "not ready" and does not look at the data.
Data goes in before the flag. x and y are stored first, then the flag. Atomic stores keep this order for every thread that reads with load().
A raised flag means complete data. Once the reader sees 1, both coordinates are guaranteed to be there: x=10 y=20.
Compatibility
Browser & Runtime Support
Atomics.store() arrived in ES2017 and accepts shared and normal integer typed arrays in modern engines.
✓ Baseline · ES2017
Atomics.store()
Supported in all modern browsers and in Node.js, Deno, and Bun.
95%Modern browser support
Google ChromeModern versions · Desktop & Mobile
Full support
Mozilla FirefoxModern versions · Desktop & Mobile
Full support
Apple SafariModern versions · macOS & iOS
Full support
Microsoft EdgeModern versions · Chromium
Full support
OperaModern versions
Full support
Samsung InternetModern versions · Android
Full support
Internet ExplorerNo Atomics object
Not supported
Node.jsCurrent releases · checked on Node 24
Supported
DenoCurrent releases
Supported
BunCurrent releases
Supported
Atomics.store()Excellent
Bottom line: Use it anywhere. Publishing data to another thread through a SharedArrayBuffer needs a cross-origin isolated page in browsers.
Frequently Asked Questions
The value you passed, converted to an integer. It does not return the old value; Atomics.exchange() does that.
The return value is not wrapped to the element type, but the stored element is. In a Uint8Array, storing 300 returns 300 while the element keeps 44.
On one thread the stored result is the same. With shared memory, Atomics.store() also guarantees ordering, so other threads that load the slot also see every write you made before it.
Write the data, then Atomics.store() a flag. The other thread reads the flag with Atomics.load(), or sleeps on it with Atomics.wait() and is woken with Atomics.notify().
Yes, into a BigInt64Array or BigUint64Array, and the value must then be a BigInt such as 10n. Other arrays need a Number.