I was reading the Mozilla Developer Network docs on Float32Arrays when I came upon
Float32Array.length
Length property whose value is 3.
... why is always 3? I also noticed that prototype property of the same name overrides it.
The Float32Array typed array represents an array of 32-bit floating point numbers (corresponding to the C float data type) in the platform byte order. If control over byte order is needed, use DataView instead. The contents are initialized to 0 .
Float32Array
is actually a function. You can check that like this
console.assert(typeof Float32Array === 'function');
And that function accepts three parameters. Quoting the signature from the same documentation,
Float32Array(buffer [, byteOffset [, length]]);
Quoting the Function.length
documentation,
length
is a property of a function object, and indicates how many arguments the function expects, i.e. the number of formal parameters.
That is why the length
property of Float32Array
is always 3.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With