JavaScript Atomics load() Method

Beginner
6 min read
Updated: Nov 2026
3 examples
Atomics

Definition

Atomics.load(typedArray, index) reads the element at index and returns it. On a single thread that looks just like typedArray[index]. The difference shows up with shared memory, memory that several threads can see at the same time: an atomic load always returns a whole value that some thread really wrote, and it is ordered with the other Atomics calls, so a value written with Atomics.store() in one worker is seen correctly in another. Use load() whenever you read a slot that another thread may be changing.

Remember
Atomics.load(typedArray, index)   -> current value

reads one element, changes nothing
pair it with Atomics.store() for writes

Uint8Array view  -> 0 .. 255
Int8Array view   -> -128 .. 127 (same bytes, other meaning)

Syntax

load() needs only the array and the position.

JavaScript
Atomics.load(typedArray, index)
CallWhat it does
Atomics.load(typedArray, index)Returns the element at index as one atomic read. The array is not changed.
Atomics.load(bigArray, index)On BigInt64Array and BigUint64Array the result is a BigInt, for example 5n.

Available since ES2017. It is the reading half of the pair Atomics.load() / Atomics.store().

Library declarations
JavaScript
Atomics.load(typedArray, index)   // returns the element value

// typedArray: Int8Array, Uint8Array, Int16Array, Uint16Array,
//             Int32Array, Uint32Array, BigInt64Array, BigUint64Array
// index:      0 .. typedArray.length - 1, otherwise RangeError

Parameters

ParameterDescription
typedArrayRequired. Any integer typed array, backed by a SharedArrayBuffer or a normal ArrayBuffer. A Float64Array, Float32Array, Uint8ClampedArray, or plain array throws a TypeError.
indexRequired. The position to read. Unlike typedArray[99], which quietly gives undefined, an invalid index throws a RangeError.

Return Value

Return ValueDescription
NumberThe current element value for the 8-, 16-, and 32-bit arrays.
BigIntThe current element value for BigInt64Array and BigUint64Array.

JavaScript Examples

Example 1 — Read a Progress Slot

A worker would write its progress percentage into slot 0. The page reads it with load(). Slot 1 was never written, so it is still 0.

JavaScript
const progress = new Int32Array(2);
Atomics.store(progress, 0, 40);

console.log(Atomics.load(progress, 0));   // 40
console.log(Atomics.load(progress, 1));   // 0
console.log(progress.length);             // 2
Try It Yourself

How It Works

  1. Write with store(). Slot 0 receives 40, as a worker reporting “40% done” would do.
  2. Read with load(). Atomics.load(progress, 0) returns 40; slot 1 still holds its starting 0.
  3. Reading never changes anything. load() has no side effects. The array keeps its 2 elements and both values.

Example 2 — The View Decides What You Read

Two typed arrays can sit on the same buffer. load() reads the same byte as 200 through a Uint8Array and as -56 through an Int8Array.

JavaScript
const buffer = new ArrayBuffer(4);
const unsigned = new Uint8Array(buffer);
const signed = new Int8Array(buffer);

Atomics.store(unsigned, 0, 200);
console.log(Atomics.load(unsigned, 0));   // 200
console.log(Atomics.load(signed, 0));     // -56
Try It Yourself

How It Works

  1. One buffer, two views. Both arrays look at the same 4 bytes of the ArrayBuffer.
  2. Store a byte through one view. In a Uint8Array the byte holds 200.
  3. Read it through the other. An Int8Array treats bytes above 127 as negative, so the same bits load as 200 - 256 = -56.

Example 3 — load() Is Stricter Than Brackets

Brackets quietly return undefined for a missing index. load() throws instead, and it rejects float arrays.

JavaScript
const slots = new Int32Array(2);
console.log(String(slots[5]));          // undefined

try {
  Atomics.load(slots, 5);
} catch (e) {
  console.log(e.name);                  // RangeError
}

try {
  Atomics.load(new Float64Array(2), 0);
} catch (e) {
  console.log(e.name);                  // TypeError
}
Try It Yourself

How It Works

  1. Brackets stay silent. slots[5] is outside the 2-element array and simply gives undefined.
  2. load() refuses bad positions. The same index throws a RangeError, which helps you spot bugs early.
  3. Floats are not allowed. Atomics only works on integer typed arrays, so a Float64Array throws a TypeError.

Browser & Runtime Support

Atomics.load() is part of ES2017 and works on shared and normal integer typed arrays in modern engines.

✓ Baseline · ES2017

Atomics.load()

Supported in all modern browsers and in Node.js, Deno, and Bun.

95% Modern browser support
Google Chrome Modern versions · Desktop & Mobile
Full support
Mozilla Firefox Modern versions · Desktop & Mobile
Full support
Apple Safari Modern versions · macOS & iOS
Full support
Microsoft Edge Modern versions · Chromium
Full support
Opera Modern versions
Full support
Samsung Internet Modern versions · Android
Full support
Internet Explorer No Atomics object
Not supported
Node.js Current releases · checked on Node 24
Supported
Deno Current releases
Supported
Bun Current releases
Supported
Atomics.load() Excellent

Bottom line: Safe everywhere. Its real job, reading memory that another thread writes, needs SharedArrayBuffer, and browsers only offer that on cross-origin isolated pages.

Frequently Asked Questions

On one thread they return the same number. With shared memory, Atomics.load() guarantees a complete value and keeps the order of other atomic operations, while a[i] does not. Atomics.load() also throws a RangeError for a bad index instead of returning undefined.
No. It only reads one element. All the other Atomics methods except isLockFree() and pause() can write.
A Number for the 8-, 16-, and 32-bit integer arrays and a BigInt for BigInt64Array and BigUint64Array.
Whenever a value is written by one thread and read by another, for example a progress counter or a ready flag in a SharedArrayBuffer used by a Web Worker.
No. Atomics works only on integer typed arrays. For floats, store a scaled integer (for example cents instead of dollars) in an Int32Array.

Next: Atomics.notify()

Wake threads that are waiting on a shared value, and count how many woke up.

notify() tutorial →

About the author

Mari Selvan M P
Mari Selvan M P 🔗

Developer, cloud engineer, and technical writer

  • Experience 12 years building web and cloud systems
  • Focus Full Stack Development, AWS, and Developer Education

I write practical tutorials so students and working developers can learn by doing—from databases and APIs to deployment on AWS.

11 people found this page helpful