This page was translated from English by the community.Learn more and join the MDN Web Docs community.
Atomics.load()
Baseline Widely available
This feature is well established and works across many devices and browser versions. It’s been available across browsers since 2021년 12월.
Atomics.load() 정적 메서드는 배열의 지정된 위치의 값을 반환합니다.
In this article
시도해 보기
// Create a SharedArrayBuffer with a size in bytesconst buffer = new SharedArrayBuffer(16);const uint8 = new Uint8Array(buffer);uint8[0] = 5;// 5 + 2 = 7console.log(Atomics.add(uint8, 0, 2));// Expected output: 5console.log(Atomics.load(uint8, 0));// Expected output: 7구문
js
Atomics.load(typedArray, index)매개 변수
typedArray정수형 형식화 배열.
Int8Array,Uint8Array,Int16Array,Uint16Array,Int32Array,Uint32Array,BigInt64Array,BigUint64Array중 하나.index값을 불러올
typedArray의 인덱스
반환 값
주어진 위치(typedArray[index])의 예전 값.
예외
typedArray가 허용된 정수형이 아닐 경우TypeError가 발생합니다.index가typedArray의 범위를 벗어날 경우RangeError가 발생합니다.
예제
>load 사용하기
js
const sab = new SharedArrayBuffer(1024);const ta = new Uint8Array(sab);Atomics.add(ta, 0, 12);Atomics.load(ta, 0); // 12명세서
| Specification |
|---|
| ECMAScript® 2026 Language Specification> # sec-atomics.load> |