DataView() 생성자

DataView() 생성자는 새로운 DataView 객체를 생성합니다.

구문

new DataView(buffer [, byteOffset [, byteLength]])

매개변수

buffer
새로운 DataView 객체의 저장소로 사용할 ArrayBuffer 또는 SharedArrayBuffer .
byteOffset Optional
새로운 뷰가 참조할 첫 번째 바이트로의 바이트 단위 오프셋. 지정하지 않을 경우 버퍼 뷰는 첫 번째 바이트부터 시작합니다.
byteLength Optional
바이트 배열의 요소 수. 지정하지 않을 경우 뷰의 길이는 버퍼의 길이와 같아집니다.

반환 값

지정한 데이터 버퍼를 나타내는 새로운 DataView 객체.

DataView 객체는 배열 버퍼의 "인터프리터"라고 생각하면 좀 더 쉽습니다. DataView는 읽기와 쓰기 모두에서 버퍼에 잘 맞도록 숫자를 올바르게 변환하는 법, 즉 정수/부동소수점 실수 변환, 엔디언 등 이진 형식으로 나타낸 숫자의 처리법을 알고 있습니다.

예외

RangeError

byteOffset 또는 byteLength 매개변수가 버퍼의 끝을 벗어남.

예를 들어, 버퍼가 16바이트 길이인데 byteOffset을 8로, byteLength를 10으로 설정할 경우 총 길이 18로서 2바이트를 초과하므로 오류가 발생합니다.

명세

Specification
ECMAScript (ECMA-262)
The definition of 'DataView constructor' in that specification.

브라우저 호환성

Update compatibility data on GitHub
DesktopMobileServer
ChromeEdgeFirefoxInternet ExplorerOperaSafariAndroid webviewChrome for AndroidFirefox for AndroidOpera for AndroidSafari on iOSSamsung InternetNode.js
DataView() constructorChrome Full support 9Edge Full support 12Firefox Full support 15IE Full support 10Opera Full support 12.1Safari Full support 5.1WebView Android Full support 4Chrome Android Full support 18Firefox Android Full support 15Opera Android Full support 12.1Safari iOS Full support 4.2Samsung Internet Android Full support 1.0nodejs Full support 0.10
DataView() without new throwsChrome Full support 11Edge Full support 13Firefox Full support 40IE No support NoOpera Full support 15Safari Full support 5.1WebView Android Full support ≤37Chrome Android Full support 18Firefox Android Full support 40Opera Android Full support 14Safari iOS Full support 5.1Samsung Internet Android Full support 1.0nodejs Full support 0.10
SharedArrayBuffer accepted as bufferChrome Full support 68
Full support 68
No support 60 — 63
Notes
Notes Chrome disabled SharedArrayBuffer on January 5, 2018 to help reduce the efficacy of speculative side-channel attacks. This was a temporary removal while mitigations were put in place.
Edge Full support 79Firefox Full support 79
Full support 79
Full support 57
Notes Disabled
Notes Support was disabled by default to mitigate speculative execution side-channel attacks (Mozilla Security Blog).
Disabled From version 57: this feature is behind the javascript.options.shared_memory preference (needs to be set to true). To change preferences in Firefox, visit about:config.
No support 55 — 57
No support 46 — 55
Disabled
Disabled From version 46 until version 55 (exclusive): this feature is behind the javascript.options.shared_memory preference (needs to be set to true). To change preferences in Firefox, visit about:config.
IE No support NoOpera No support NoSafari No support 10.1 — 11WebView Android No support 60 — 63
Notes
No support 60 — 63
Notes
Notes Chrome disabled SharedArrayBuffer on January 5, 2018 to help reduce the efficacy of speculative side-channel attacks. This is intended as a temporary measure until other mitigations are in place.
Chrome Android No support 60 — 63
Notes
No support 60 — 63
Notes
Notes Chrome disabled SharedArrayBuffer on January 5, 2018 to help reduce the efficacy of speculative side-channel attacks. This is intended as a temporary measure until other mitigations are in place.
Firefox Android Full support 79
Full support 79
Full support 57
Notes Disabled
Notes Support was disabled by default to mitigate speculative execution side-channel attacks (Mozilla Security Blog).
Disabled From version 57: this feature is behind the javascript.options.shared_memory preference (needs to be set to true). To change preferences in Firefox, visit about:config.
No support 55 — 57
No support 46 — 55
Disabled
Disabled From version 46 until version 55 (exclusive): this feature is behind the javascript.options.shared_memory preference (needs to be set to true). To change preferences in Firefox, visit about:config.
Opera Android No support NoSafari iOS No support 10.3 — 11Samsung Internet Android No support No
Notes
No support No
Notes
Notes Chrome disabled SharedArrayBuffer on January 5, 2018 to help reduce the efficacy of speculative side-channel attacks. This is intended as a temporary measure until other mitigations are in place.
nodejs Full support 8.10.0

Legend

Full support  
Full support
No support  
No support
See implementation notes.
See implementation notes.
User must explicitly enable this feature.
User must explicitly enable this feature.

같이 보기