This page was translated from English by the community. Learn more and join the MDN Web Docs community.

View in English Always switch to English

ArrayBuffer.prototype.resizable

Baseline 2024
Newly available

Since โจJuly 2024โฉ, this feature works across the latest devices and browser versions. This feature might not work in older devices or browsers.

ArrayBuffer ์ธ์Šคํ„ด์Šค์˜ resizable ์ ‘๊ทผ์ž ์†์„ฑ์€ ๋ฐฐ์—ด ๋ฒ„ํผ๊ฐ€ ํฌ๊ธฐ ์กฐ์ •์ด ๊ฐ€๋Šฅํ•œ์ง€ ๋ถˆ๊ฐ€ํ•œ์ง€ ์—ฌ๋ถ€๋ฅผ ๋ฐ˜ํ™˜ํ•ฉ๋‹ˆ๋‹ค.

์‹œ๋„ํ•ด ๋ณด๊ธฐ

const buffer1 = new ArrayBuffer(8, { maxByteLength: 16 });
const buffer2 = new ArrayBuffer(8);

console.log(buffer1.resizable);
// Expected output: true

console.log(buffer2.resizable);
// Expected output: false

์„ค๋ช…

resizeable ์†์„ฑ์€ ์„ค์ • ์ ‘๊ทผ์ž ํ•จ์ˆ˜๊ฐ€ undefined์ธ ์ ‘๊ทผ์ž ์†์„ฑ์œผ๋กœ ์ด ์†์„ฑ์€ ์ฝ์„ ์ˆ˜ ๋งŒ ์žˆ์Šต๋‹ˆ๋‹ค. ์ด ๊ฐ’์€ ๋ฐฐ์—ด์ด ์ƒ์„ฑ๋  ๋•Œ ์„ค์ •๋ฉ๋‹ˆ๋‹ค. ์ƒ์„ฑ์ž์—์„œ maxByteLength ์˜ต์…˜์„ ์„ค์ •ํ–ˆ๋‹ค๋ฉด resizeable์€ true๋ฅผ ๋ฐ˜ํ™˜ํ•˜๊ณ  ๊ทธ๋ ‡์ง€ ์•Š์œผ๋ฉด false๋ฅผ ๋ฐ˜ํ™˜ํ•ฉ๋‹ˆ๋‹ค.

์˜ˆ์ œ

resizable ์‚ฌ์šฉํ•˜๊ธฐ

์ด ์˜ˆ์ œ์—์„œ๋Š” ์ตœ๋Œ€ 16๋ฐ”์ดํŠธ ๊ธธ์ด๋กœ ํฌ๊ธฐ๋ฅผ ์กฐ์ •ํ•  ์ˆ˜ ์žˆ๋Š” 8๋ฐ”์ดํŠธ ๋ฒ„ํผ๋ฅผ ๋งŒ๋“  ๋‹ค์Œ resizable ์†์„ฑ์„ ํ™•์ธํ•˜๊ณ  resizable์ด true๋ฅผ ๋ฐ˜ํ™˜ํ•˜๋ฉด ํฌ๊ธฐ๋ฅผ ์กฐ์ •ํ•ฉ๋‹ˆ๋‹ค.

js
const buffer = new ArrayBuffer(8, { maxByteLength: 16 });

if (buffer.resizable) {
  console.log("Buffer is resizable!");
  buffer.resize(12);
}

๋ช…์„ธ์„œ

Specification
ECMAScriptยฎ 2026 Language Specification
# sec-get-arraybuffer.prototype.resizable

๋ธŒ๋ผ์šฐ์ € ํ˜ธํ™˜์„ฑ

๊ฐ™์ด ๋ณด๊ธฐ