-
Notifications
You must be signed in to change notification settings - Fork 38
Expand file tree
/
Copy pathArrayBuffer.html
More file actions
39 lines (39 loc) · 9.44 KB
/
Copy pathArrayBuffer.html
File metadata and controls
39 lines (39 loc) · 9.44 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
<!DOCTYPE html><html><head><meta charset="utf-8"><title>ArrayBuffer JavaScript API</title><meta name="description" content="Interactive API reference for the JavaScript ArrayBuffer Object. ArrayBuffers are fixed length buffer of bytes. The bytes in an ArrayBuffer are only accessible through a DataView (for heterogenous da"><link rel="stylesheet" type="text/css" href="styles.css"><script type="text/javascript">var _gaq = _gaq || [];
_gaq.push(['_setAccount', 'UA-23450559-1']);
_gaq.push(['_trackPageview']);
(function() {
var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
})();</script></head><body><script>if (sessionStorage.collapsed === 'true') {
document.body.classList.add('members-collapsed');
}
if (localStorage.theme) {
document.body.parentElement.classList.add(localStorage.theme);
}</script><div class="topnav"><a href="/">JavaScripture</a><div class="bookmarks"><a class="bookmark contribute" href="https://github.com/nkronlage/JavaScripture">Contribute via GitHub</a> <a class="bookmark" href="/feedback">Feedback</a></div></div><div class="container"><nav class="leftnav"><div id="searchContainer"><input id="searchBox" type="text" placeholder="Search (Ctrl + S)" autocomplete="false"><div id="resultsBox" style="display:none;"></div></div><div id="apichooser"><a href="#" onclick="openApiChooser(); return false;"><div class="arrow"></div><span id="selectedsets"></span></a><div id="obscure"></div><div id="apisets"><ul></ul></div></div><div class="toc"><h2>ArrayBuffer</h2><div class="navgroup"><div class="group"><a href="#Constructors">Constructors</a></div><div class="group collapsed"><a href="#InstanceProperties" onclick="expandoClicked(this.parentNode); return false;"><div class="arrow"></div>Instance Properties</a><div class="subgroup"><a href="#byteLength">byteLength</a></div></div><div class="group collapsed"><a href="#InstanceMethods" onclick="expandoClicked(this.parentNode); return false;"><div class="arrow"></div>Instance Methods</a><div class="subgroup"><a href="#slice_Number_Number">slice</a></div></div><div class="group collapsed"><a href="#ArrayBufferMethods" onclick="expandoClicked(this.parentNode); return false;"><div class="arrow"></div>ArrayBuffer Methods</a><div class="subgroup"><a href="#isView_Object">isView</a></div></div></div><h2>TypedArrays API</h2><div id="related-apis" class="navgroup"></div><h2>All API</h2><div id="rootObjs" class="navgroup"><span class="empty">No API set selected.</span></div></div></nav><div class="content"><h1 class="declaration"><span class="object">ArrayBuffer</span> <span class="type">: <a href="/Object">Object</a></span></h1><div class="metadata"><span>constructor</span></div><div class="objectdescription">ArrayBuffers are fixed length buffer of bytes. The bytes in an ArrayBuffer are only accessible through a <a href="DataView"><code>DataView</code></a> (for heterogenous data) or one of the typed arrays (for homogeneous data): <a href="BigInt64Array"><code>BigInt64Array</code></a>, <a href="BigUint64Array"><code>BigUint64Array</code></a>, <a href="Float32Array"><code>Float32Array</code></a>, <a href="Float64Array"><code>Float64Array</code></a>, <a href="Int8Array"><code>Int8Array</code></a>, <a href="Int16Array"><code>Int16Array</code></a>, <a href="Int32Array"><code>Int32Array</code></a>, <a href="Uint8Array"><code>Uint8Array</code></a>, <a href="Uint8ClampedArray"><code>Uint8ClampedArray</code></a>, <a href="Uint16Array"><code>Uint16Array</code></a>, <a href="Uint32Array"><code>Uint32Array</code></a>. Multiple DataView and typed arrays can be applied to one ArrayBuffer and changes to one view can be seen in the others immediately.<div class="membermetadata"><a href="http://www.khronos.org/registry/typedarray/specs/latest/#5" class="spec">Spec</a></div></div><div><a name="Constructors"></a><h2>Constructors</h2><div class="member"><div class="expand-members" title="Toggle showing all descriptions and examples"></div><a name="ArrayBuffer"></a> <a name="new_ArrayBuffer_Number"></a><div class="declaration">new <span class="membername primary">ArrayBuffer</span>(<span class="membername">byteLength</span> : <a class="membertype" href="/Number">Number</a>) : <a class="membertype" href="/ArrayBuffer">ArrayBuffer</a></div><div class="member-body"><p class="description">Allocates a new <code>ArrayBuffer</code> of the specified length where each byte starts as <code>0</code>.</p><div class="example"><div class="codePanel"><h4>Example:</h4><textarea class="code" rows="12" cols="60" wrap="off">
var buffer = new ArrayBuffer(12);
var dataView = new DataView(buffer);
var int8View = new Int8Array(buffer);
dataView.setInt32(0, 0x1234ABCD);
console.log(dataView.getInt32(0).toString(16));
console.log(dataView.getInt8(0).toString(16));
console.log(int8View[0].toString(16));
</textarea><a onclick='executeExample(this.parentNode.parentNode, "ArrayBuffer.ArrayBuffer"); return false' href="#" class="run">Run</a></div><div class="resultsPanel"><h4>Results:</h4><div style="position: relative"><div class="errormessage" style="display: none"></div><pre class="results"> </pre></div></div></div><p></p></div></div></div><div><a name="InstanceProperties"></a><h2>Instance Properties</h2><div class="member"><div class="expand-members" title="Toggle showing all descriptions and examples"></div><a name="byteLength"></a><div class="declaration"><span class="membername primary">byteLength</span> : <a class="membertype" href="/Number">Number</a> <span class="metadata">readonly</span></div><div class="member-body"><p class="description">The length of <code>this</code> in bytes.</p><div class="example"><div class="codePanel"><h4>Example:</h4><textarea class="code" rows="12" cols="60" wrap="off">
var buffer = new ArrayBuffer(12);
console.log(buffer.byteLength);
</textarea><a onclick='executeExample(this.parentNode.parentNode, "ArrayBuffer.byteLength"); return false' href="#" class="run">Run</a></div><div class="resultsPanel"><h4>Results:</h4><div style="position: relative"><div class="errormessage" style="display: none"></div><pre class="results"> </pre></div></div></div><p></p></div></div></div><div><a name="InstanceMethods"></a><h2>Instance Methods</h2><div class="member"><div class="expand-members" title="Toggle showing all descriptions and examples"></div><a name="slice"></a> <a name="slice_Number_Number"></a><div class="declaration"><span class="membername primary">slice</span>(<span class="membername">beginByte</span> : <a class="membertype" href="/Number">Number</a>, <span class="optional">[<span class="membername">endByte</span> : <a class="membertype" href="/Number">Number</a>]</span>) : <a class="membertype" href="/ArrayBuffer">ArrayBuffer</a></div><div class="member-body"><p class="description">Creates a new ArrayBuffer with a copy of the bytes of <code>this</code> between <code>beginByte</code> (inclusive) and <code>endByte</code> (exclusive). If <code>endByte</code> is not specified, <code>this.byteLength</code> is used. Changes to <code>this</code> do not affect the copy returned by <code>slice</code>.</p><div class="example"><div class="codePanel"><h4>Example:</h4><textarea class="code" rows="12" cols="60" wrap="off">
var buffer = new ArrayBuffer(12);
var x = new Int32Array(buffer);
x[1] = 1234;
var slice = buffer.slice(4);
var y = new Int32Array(slice);
console.log(x[1]);
console.log(y[0]);
x[1] = 6789;
console.log(x[1]);
console.log(y[0]);
</textarea><a onclick='executeExample(this.parentNode.parentNode, "ArrayBuffer.slice"); return false' href="#" class="run">Run</a></div><div class="resultsPanel"><h4>Results:</h4><div style="position: relative"><div class="errormessage" style="display: none"></div><pre class="results"> </pre></div></div></div><p></p></div></div></div><div><a name="ArrayBufferMethods"></a><h2>ArrayBuffer Methods</h2><div class="member"><div class="expand-members" title="Toggle showing all descriptions and examples"></div><a name="isView"></a> <a name="isView_Object"></a><div class="declaration"><span class="membername primary">isView</span>(<span class="membername">value</span> : <a class="membertype" href="/Object">Object</a>) : <a class="membertype" href="/Boolean">Boolean</a></div><div class="member-body"><p class="description">Returns <code>true</code> if <code>value</code> is an <a href="/ArrayBufferView">ArrayBufferView</a>.</p><div class="example"><div class="codePanel"><h4>Example:</h4><textarea class="code" rows="12" cols="60" wrap="off">
console.log(ArrayBuffer.isView(new Int32Array()));
console.log(ArrayBuffer.isView(new Float64Array()));
console.log(ArrayBuffer.isView(new Array()));
</textarea><a onclick='executeExample(this.parentNode.parentNode, "ArrayBuffer.isView"); return false' href="#" class="run">Run</a></div><div class="resultsPanel"><h4>Results:</h4><div style="position: relative"><div class="errormessage" style="display: none"></div><pre class="results"> </pre></div></div></div><p></p></div></div></div><div class="bottomnav"><a href="/">home</a> <a href="/license">license</a> <a href="https://github.com/nkronlage/JavaScripture">contribute</a> <a href="/feedback">feedback</a> <a id="toggle-theme" href="#">toggle light/dark mode</a></div><div class="copyright">Copyright © JavaScripture Contributors</div></div></div></body><script src="javascripture.js"></script></html>