This page was translated from English by the community.Learn more and join the MDN Web Docs community.
SharedArrayBuffer.prototype.grow()
Baseline 2024Newly available
Since July 2024, this feature works across the latest devices and browser versions. This feature might not work in older devices or browsers.
SharedArrayBuffer 인스턴스의grow() 메서드는SharedArrayBuffer를 바이트 단위의 명시된 크기까지 늘립니다.
In this article
구문
js
grow(newLength)매개변수
newLength크기를 재조정할
SharedArrayBuffer의 바이트 단위의 새로운 길이.
반환 값
없음 (undefined).
예외
TypeErrorSharedArrayBuffer가 커질 수가 없을 때 발생합니다.RangeErrornewLength가SharedArrayBuffer의maxByteLength보다 크거나byteLength보다 작은 경우 발생합니다.
설명
grow() 메서드는SharedArrayBuffer가성장 가능하며 새로운 크기가SharedArrayBuffer의maxByteLength보다 작거나 같은 경우newLength 매개변수로 지정된 크기까지SharedArrayBuffer를 늘립니다. 새로운 바이트는 0으로 초기화됩니다.
예제
>grow() 사용하기
이 예제에서는 최대 길이 16바이트까지 늘릴 수 있는 8바이트 버퍼를 생성한 다음growable 속성을 확인하여growable이true를 반환하면 버퍼를 늘립니다.
js
const buffer = new SharedArrayBuffer(8, { maxByteLength: 16 });if (buffer.growable) { console.log("SAB is growable!"); buffer.grow(12);}명세서
| Specification |
|---|
| ECMAScript® 2026 Language Specification> # sec-sharedarraybuffer.prototype.grow> |