TopLevel
Class Uint8ClampedArray
Uint8ClampedArray
An optimized array to store 8-bit unsigned integer numbers. If a value outside of the range 0-255 is attempted to be
set, either 0 or 255 is set instead. Elements of this array are stored in an ArrayBuffer object.
API Versioned:
From version 21.2.
Constants
BYTES_PER_ELEMENT
:
Number = 1
Number value of the element size.
Properties
buffer
:
ArrayBuffer
The array buffer referenced by this typed array.
byteLength
:
Number
The number of bytes in the array buffer used by this typed array.
byteOffset
:
Number
The start offset for this typed array within the array buffer.
length
:
Number
The number of elements.
Constructor Summary
Uint8ClampedArray()
Creates an empty array.
Uint8ClampedArray(length
:
Number)
Creates an array with the given element count.
Uint8ClampedArray(typedArray
:
Object)
Creates an array as a copy of the passed typed array.
Uint8ClampedArray(array
:
Array)
Creates an array as a copy of the passed array.
Uint8ClampedArray(buffer
:
ArrayBuffer, byteOffset
:
Number, length
:
Number)
Creates a typed array as a view on the given ArrayBuffer.
Method Summary
set(values
:
Object, offset
:
Number)
:
void
Copies all values from the source array into this typed array.
subarray(begin
:
Number, end
:
Number)
:
Uint8ClampedArray
Returns a new array object based on the same ArrayBuffer store.
Methods inherited from class
Object
assign, create, create, defineProperties, defineProperty, entries, freeze, fromEntries, getOwnPropertyDescriptor, getOwnPropertyNames, getOwnPropertySymbols, getPrototypeOf, hasOwnProperty, is, isExtensible, isFrozen, isPrototypeOf, isSealed, keys, preventExtensions, propertyIsEnumerable, seal, setPrototypeOf, toLocaleString, toString, valueOf, values
Constructor Detail
Uint8ClampedArray
public Uint8ClampedArray(length
:
Number)
Creates an array with the given element count.
Parameters:
length
-
The number of elements.
Uint8ClampedArray
public Uint8ClampedArray(typedArray
:
Object)
Creates an array as a copy of the passed typed array.
Parameters:
typedArray
-
The source typed array.
Uint8ClampedArray
public Uint8ClampedArray(array
:
Array)
Creates an array as a copy of the passed array.
Parameters:
array
-
The source array.
Uint8ClampedArray
Creates a typed array as a view on the given ArrayBuffer.
Parameters:
buffer
-
The array buffer storage object.
byteOffset
-
Optional. The offset within the array buffer in bytes.
length
-
Optional. The number of elements for the target typed array. The passed array buffer must be large enough to store the number of elements specified.
Method Detail
get
Returns the value at the specified index.
Note: This is not ECMAScript standard. Use array element access syntax for single value access.
Note: This is not ECMAScript standard. Use array element access syntax for single value access.
Parameters:
index
-
The index to use.
Returns:
The value at the specified index.
set
Copies all values from the source array into this typed array.
Parameters:
values
-
The source values. Can be an array or a typed array.
offset
-
Optional. Target offset.
subarray
Returns a new array object based on the same ArrayBuffer store.
Parameters:
begin
-
Optional. The first included element.
end
-
Optional. The index of the end. This element is not included.
Returns:
The new array object.