Java Reference
In-Depth Information
Because typed arrays are array-like objects, you can use most of the methods of the
Array
object on typed arrays. The following code shows how to use the
join()
method to
concatenate elements of an
Int32Array
:
// Create an Int32Array of 4 elements
var ids = new Int32Array(4);
// Populate the array
ids[0] = 101;
ids[1] = 102;
ids[2] = 103;
ids[3] = 104;
// Call the join() method of the Array.prototype object and print the result
var idsList = Array.prototype.join.call(ids);
print(idsList);
101,102,103,104
DataView View
The
DataView
view provides low-level interface to read and write different types of data
from an
ArrayBuffer
. Typically, you use a
DataView
when the data in an
ArrayBuffer
contains different types of data in different regions of the same
ArrayBuffer
. Notice that
DataView
is not a typed array; it is simply a view of an
ArrayBuffer
. The signature of the
DataView
constructor is:
DataView(arrayBuffer, byteOffset, byteLength)
It creates a view of the specified
arrayBuffer
referencing
byteLength
bytes from
byteOffset
index. If
byteLength
is unspecified, it references
arrayBuffer
starting
at
byteOffset
and to the end. If both
byteOffset
and
byteLength
are unspecified, it
references the entre
arrayBuffer
.
Unlike typed array view types, the
DataView
object can use mixed data types values,
so it does not have a
length
property. Like typed arrays, it has
buffer
,
byteOffset
, and
byteLength
properties. It contains the following getter and setter methods for reading
and writing different types of values:
getInt8(byteOffset)
•
getUint8(byteOffset)
•
getInt16(byteOffset, littleEndian)
•
getUint16(byteOffset, littleEndian)
•
getInt32(byteOffset, littleEndian)
•
Search WWH ::
Custom Search