gpt4 book ai didi

javascript - 为什么 Float32Array.length 的值总是 3?

转载 作者:数据小太阳 更新时间:2023-10-29 04:10:25 24 4
gpt4 key购买 nike

我正在阅读 the Mozilla Developer Network docs on Float32Arrays当我遇到的时候

Float32Array.length
Length property whose value is 3.

...为什么总是 3?我还注意到同名的原型(prototype)属性覆盖了它。

最佳答案

Float32Array 实际上是一个函数。你可以这样检查

console.assert(typeof Float32Array === 'function');

那个函数接受三个参数。引用同一文档中的签名,

Float32Array(buffer [, byteOffset [, length]]);

引用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.

这就是 Float32Arraylength 属性始终为 3 的原因。

关于javascript - 为什么 Float32Array.length 的值总是 3?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29456981/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com