2.9.1.2.5.2 [[GetOwnProperty]] ( P)

TypeArray objects use a variation of the [[GetOwnProperty]] internal method used for other native ECMAScript objects (8.12.1). This special internal method provides access to named properties corresponding to the individual index values of the TypeArray objects.

When the [[GetOwnProperty]] internal method of A is called with property name P, the following steps are taken:

  1. Let desc be the result of calling the default [[GetOwnProperty]] internal method (8.12.1) on A with argument P.

  2. If desc is not undefined return desc.

  3. If ToString(abs(ToInteger(P))) is not the same value as P, return undefined.

  4. Let length be the result of a calling [[Get]] on A with parameter "length"

  5. Let index be ToInteger(P).

  6. If length ≤ index, return undefined.

  7. Let isLittleEndian be true if the platform endianness is little endian, else false.

  8. Let value be the result of calling the GetValueFromBuffer internal operation with arguments A.buffer.[[NativeBuffer]], A.byteOffset, index, Type, and littleEndian.

  9. Return a Property Descriptor { [[Value]]: value, [[Enumerable]]: true, [[Writable]]: true, [[Configurable]]: false }

The internal operation GetValueFromBuffer takes three parameters, a native buffer nativeBuffer, an integer byteOffset, an integer index, a Type valueType, and a boolean isLittleEndian.  It operates as follows:

  1. Let size be the size in bytes of the type valueType.

  2. Let bytes be the array of bytes from nativeBuffer between offset byteOffset+(index*size) and offset byteOffset+((index+1)*size)-1 inclusive.

  3. Let rawValue be the result of convert the array bytes to a value of type valueType, using little endian if isLittleEndian is true, otherwise big endian.

  4. If valueType is Float32 and rawValue is a Float32 representation of IEEE754 NaN, return the NaN Number value.

  5. Else, if valueType is Float64 and rawValue is a Float64 representation of IEEE754 NaN, return the NaN Number value.

  6. Else, return the Number value that that represents the same numeric value as rawValue