CKTIS / JavaScript
TypedArray.length — number of elements in a view
TypedArray.length denotes the number of elements in a typed array, not its byte count. Read it from an instance, such as values.length; it is not a way to resize the view.
Version: ECMAScript and Web APIs; exact feature edition and browser support reviewed per entry; Node 24 in repository does not prove browser API support
Syntax
typedArray.lengthTypedArray.length here denotes the instance property documented as TypedArray.prototype.length. Read it with typedArray.length, without call parentheses. TypedArray is the shared abstraction for concrete types such as Uint16Array, not a global constructor available for direct use.
length counts the view's elements. byteLength counts the view's bytes, whereas buffer.byteLength describes the entire buffer. Each Uint16Array element occupies 2 bytes, so a view with a length of 3 has a byteLength of 6. A view may cover only part of its buffer. In the constructor, byteOffset is specified in bytes and length in elements.
The property is an accessor without a setter: assigning to length does not resize a typed array. With a resizable buffer, however, a length-tracking view can change its length as the buffer changes. If shrinking the buffer makes the view's range invalid, reading the property returns 0, including for a fixed-length view. Check resizable-buffer support separately; access to length alone does not establish that support.
Examples
const buffer = new ArrayBuffer(12);
const values = new Uint16Array(buffer, 2, 3);
console.log(values.length);
console.log(values.byteLength);
console.log(buffer.byteLength);Result
3 6 12
The displayed code and declared result were verified in an isolated environment using the method recorded in the verification evidence for this exact version.