在线文档教程

Float64Array

Float64Array

Float64Array 类型数组代表的是平台字节顺序为64位的浮点数型数组(对应于 C 浮点数据类型) 。 如果需要控制字节顺序, 使用DataView 替代。其内容初始化为0。一旦建立起来,你可以使用这个对象的方法对其元素进行操作,或者使用标准数组索引语法 (使用方括号)。

语法

new Float64Array( // new in ES2017 new Float64Array(length new Float64Array(typedArray new Float64Array(object new Float64Array(buffer [, byteOffset [, length]]

更多的语法信息和参数,参见TypedArray.

属性

Float64Array.BYTES_PER_ELEMENT返回元素字节数。 在Float64Array的情况下返回8。

方法

Float64Array.from()从一个类数组对象或可遍历对象创建一个新的Float64Array。参见Array.from()。

Float64Array 属性

所有的Float64Array对象都继承自 %TypedArray%.prototype

特性

Float64Array.prototype.constructor返回创建这个实例原型的函数。 这是Float64Array 默认的构造函数。

方法

Float64Array.prototype.copyWithin()从数组复制元素。参见Array.prototype.copyWithin()

示例

不同方法创建 Float64Array:

// From a length var float64 = new Float64Array(2 float64[0] = 42; console.log(float64[0] // 42 console.log(float64.length // 2 console.log(float64.BYTES_PER_ELEMENT // 8 // From an array var arr = new Float64Array([21,31] console.log(arr[1] // 31 // From another TypedArray var x = new Float64Array([21, 31] var y = new Float64Array(x console.log(y[0] // 21 // From an ArrayBuffer var buffer = new ArrayBuffer(32 var z = new Float64Array(buffer, 0, 4 // From an iterable var iterable = function*(){ yield* [1,2,3]; }( var float64 = new Float64Array(iterable // Float64Array[1, 2, 3]

规范

SpecificationStatusComment
Typed Array SpecificationObsoleteSuperseded by ECMAScript 2015.
ECMAScript 2015 (6th Edition, ECMA-262)The definition of 'TypedArray constructors' in that specification.StandardInitial definition in an ECMA standard. Specified that new is required.
ECMAScript Latest Draft (ECMA-262)The definition of 'TypedArray constructors' in that specification.DraftECMAScript 2017 changed the Float64Array constructor to use the ToIndex operation and allows constructors with no arguments.

浏览器支持

FeatureChromeEdgeFirefox (Gecko)Internet ExplorerOperaSafari
Basic support7.0(Yes)4.0 (2)1011.65.1
new is required??44 (44)???
Iterable in constructor??52 (52)???
Constructor without arguments??55 (55)???

FeatureAndroidChrome for AndroidEdgeFirefox Mobile (Gecko)IE MobileOpera MobileSafari Mobile
Basic support4.0(Yes)(Yes)4.0 (2)1011.64.2
new is required???44.0 (44)???
Iterable in constructor???52.0 (52)???
Constructor without arguments???55.0 (55)???