현재 번역은 완벽하지 않습니다. 한국어로 문서 번역에 동참해주세요.
Summary
ArrayBuffer객체는 일반적이 길이가 정해진 원시 이진 데이터 버퍼를 나타내는 데 쓰입니다. ArrayBuffer에 담긴 정보를 직접 수정하는 것은 불가능하지만, 대신 타입이 있는 배열이나 특정 포맷의 버퍼를 나타내는 DataView를 생성하고 그것을 이용해 버퍼의 내용물을 읽고 쓸 수 있습니다.
생성
new ArrayBuffer(length)
인자
- length
- 바이트 단위로 나타낸 버퍼에 저장된 길이
반환값
새로운 ArrayBuffer 객체가 지정된 길이로 만들어져 반환됩니다. 새 객체의 내용물은 0으로 초기화됩니다.
설명
ArrayBuffer 생성자는 바이트 단위의 길이가 주어지면 해당하는 길이의 ArrayBuffer 객체를 생성합니다.
Getting an array buffer from existing data
Properties
- ArrayBuffer.length
ArrayBuffer생성자의 length 속성이며, 값은 1이다.ArrayBuffer.prototype- 모든
ArrayBuffer객체에 속성을 추가할 수 있게 한다.
메소드
ArrayBuffer.isView(arg)- 타입이 있는 배열이나
DataView처럼arg가 ArrayBuffer의 view 중 하나라면true를 반환하고, 아니라면false를 반환한다. ArrayBuffer.transfer(oldBuffer [, newByteLength])-
Returns a new
ArrayBufferwhose contents are taken from theoldBuffer's data and then is either truncated or zero-extended bynewByteLength.
ArrayBuffer instances
ArrayBuffer 의 모든 인스턴스들은 ArrayBuffer.prototype 를 통해 상속받는다.
Properties
- ArrayBuffer.prototype.constructor
-
Specifies the function that creates an object's prototype. The initial value is the standard built-in
ArrayBufferconstructor. -
ArrayBuffer.prototype.byteLengthRead only - The size, in bytes, of the array. This is established when the array is constructed and cannot be changed. Read only.
Methods
-
ArrayBuffer.prototype.slice() -
Returns a new
ArrayBufferwhose contents are a copy of thisArrayBuffer's bytes frombegin, inclusive, up toend, exclusive. If eitherbeginorendis negative, it refers to an index from the end of the array, as opposed to from the beginning.
Example
이 예제에서는 8 바이트 크기의 버퍼를 생성하고 이를 Int32Array에 참조시켰습니다.
var buffer = new ArrayBuffer(8); var view = new Int32Array(buffer);
Specifications
| Specification | Status | Comment |
|---|---|---|
| Typed Array Specification | Obsolete | Superseded by ECMAScript 6. |
| ECMAScript 6 (ECMA-262) The definition of 'ArrayBuffer' in that specification. |
Release Candidate | Initial definition in an ECMA standard. |
Browser compatibility
| Feature | Chrome | Firefox (Gecko) | Internet Explorer | Opera | Safari |
|---|---|---|---|---|---|
| Basic support | 7.0 | 4.0 (2) | 10 | 11.6 | 5.1 |
| Feature | Android | Chrome for Android | Firefox Mobile (Gecko) | IE Mobile | Opera Mobile | Safari Mobile |
|---|---|---|---|---|---|---|
| Basic support | 4.0 | (Yes) | 4.0 (2) | 10 | 11.6 | 4.2 |