Atomics.pause() is a tiny hint to the processor: “I am in a spin-wait loop, checking a value over and over.” A spin-wait loop is a loop that keeps reading a shared value until another thread changes it. On many CPUs the hint lets the core save power and give way to other work for a moment. The method does not sleep, does not wait for anything, does not read or write any memory, and always returns undefined. It is one of the newest Atomics methods, so check for it with typeof Atomics.pause === "function" before you rely on it.
Remember
Atomics.pause() -> undefined
Atomics.pause(iterationNumber) -> undefined
a hint only: no sleep, no memory change
argument: undefined or an integer (else TypeError)
while (Atomics.load(flag, 0) === 0) Atomics.pause();
Syntax
Call it with no argument, or pass how many times the loop has spun so far.
JavaScript
Atomics.pause()
Atomics.pause(iterationNumber)
Call
What it does
Atomics.pause()
Gives the CPU a short spin-loop hint and returns undefined.
Atomics.pause(iterationNumber)
The same hint, plus how many times you have already spun. Engines may wait a little longer for bigger numbers (a “backoff”).
A recent addition to the language, newer than Atomics.waitAsync(). Node.js 24 has it; in browsers only the newest versions do, so feature-detect it.
Library declarations
JavaScript
Atomics.pause() // returns undefined
Atomics.pause(iterationNumber) // returns undefined
// iterationNumber: undefined or an integral Number
// 1.5, "3", or null throw a TypeError (no conversion)
Parameters
Parameter
Description
iterationNumber
Optional. How many times the loop has spun. It must be undefined or an integer Number. It is not converted: 1.5, "3", and null throw a TypeError.
Return Value
Return Value
Description
undefined
Always. The method has no result and no visible effect on your data.
JavaScript Examples
Example 1 — A Hint With No Visible Effect
Call pause() next to some data and check what happened: it returns undefined and the data is untouched.
JavaScript
const data = new Int32Array(1);
Atomics.store(data, 0, 5);
const result = Atomics.pause();
console.log(String(result)); // undefined
console.log(Atomics.load(data, 0)); // 5
console.log(typeof Atomics.pause); // function
The Try It page checks typeof Atomics.pause === "function" first. If your browser does not have Atomics.pause() yet, it says so and shows the output above.
How It Works
Nothing comes back. The result is undefined; String() turns it into text for printing.
Memory is untouched. pause() takes no array, so the stored 5 is still 5.
Detect it like any new feature.typeof Atomics.pause is "function" where the method exists and "undefined" in older engines.
Example 2 — Spin Until a Flag Is Set
A loop checks a flag with load() and calls pause() on every turn. To keep the example on one thread, the loop itself sets the flag on spin 5, standing in for another thread. A limit of 100 spins keeps it from looping forever.
JavaScript
const flag = new Int32Array(1);
let spins = 0;
while (Atomics.load(flag, 0) === 0 && spins < 100) {
Atomics.pause(spins);
spins++;
if (spins === 5) Atomics.store(flag, 0, 1); // pretend another thread did this
}
console.log("spins: " + spins); // spins: 5
console.log("flag: " + Atomics.load(flag, 0)); // flag: 1
The Try It page checks typeof Atomics.pause === "function" first. If your browser does not have Atomics.pause() yet, it says so and shows the output above.
How It Works
Check, hint, repeat. Each turn reads the flag with Atomics.load(); while it is 0 the loop calls Atomics.pause(spins).
Something sets the flag. Here the loop itself stores 1 on spin 5. In real code a worker would do it.
Always add a limit. The spins < 100 check stops a runaway loop. After about that many spins, switch to a real sleep such as Atomics.wait().
Example 3 — Which Arguments Are Allowed
Unlike most Atomics methods, pause() does not convert its argument. Integers are fine, even negative ones; anything else is a TypeError.
JavaScript
function check(arg) {
try {
Atomics.pause(arg);
return "ok";
} catch (e) {
return e.name;
}
}
console.log(check(10)); // ok
console.log(check(undefined)); // ok
console.log(check(-1)); // ok
console.log(check(1.5)); // TypeError
console.log(check("3")); // TypeError
The Try It page checks typeof Atomics.pause === "function" first. If your browser does not have Atomics.pause() yet, it says so and shows the output above.
How It Works
Integers pass. 10 and even -1 are integral Numbers, so pause() accepts them and returns normally.
Leaving it out is fine.undefined means “no iteration number”, the same as calling Atomics.pause().
No automatic conversion.1.5 is not an integer and "3" is a string, so both throw a TypeError instead of being converted.
Compatibility
Browser & Runtime Support
Atomics.pause() is one of the newest additions to JavaScript. Engines added it only recently.
✓ New · feature-detect
Atomics.pause()
Checked in Node.js 24. In browsers it is limited to the newest versions, so test for it with typeof before calling it.
NewSupport is still growing
Google ChromeNewest versions only
Check version
Mozilla FirefoxNewest versions only
Check version
Apple SafariNewest versions only
Check version
Microsoft EdgeNewest versions only
Check version
OperaNewest versions only
Check version
Samsung InternetNewest versions only
Check version
Internet ExplorerNo Atomics object
Not supported
Node.jsAvailable in Node 24 (checked)
Supported
DenoNewest versions only
Check version
BunNewest versions only
Check version
Atomics.pause()Newest engines only
Bottom line: Safe to use behind a check: const pause = typeof Atomics.pause === "function" ? Atomics.pause : function () {};. Leaving the hint out never changes what your program computes. It does not need SharedArrayBuffer.
Frequently Asked Questions
It tells the CPU that the current thread is spinning in a wait loop. It returns undefined and does not read, write, or wait for anything.
No. The thread keeps running. For waits longer than a few spins, use Atomics.wait() in a worker or Atomics.waitAsync(), which really let the thread rest.
It is the number of times the loop has spun so far. An engine may use it to pause a little longer on later spins. It must be undefined or an integer.
pause() does not convert its argument. Only undefined or an integral Number is allowed, so strings, null, and fractions throw a TypeError.
Check typeof Atomics.pause === "function" first and fall back to an empty function. The hint is optional, so skipping it does not change your results.