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
๋ฅผ ๋ฐํํ๋ฉด ํฌ๊ธฐ๋ฅผ ์กฐ์ ํฉ๋๋ค.
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 |
๋ธ๋ผ์ฐ์ ํธํ์ฑ
Loadingโฆ