Float64Array
类型数组代表的是平台字节顺序为64位的浮点数型数组(对应于 C 浮点数据类型) 。 如果需要控制字节顺序, 使用 DataView
替代。其内容初始化为0
。一旦建立起来,你可以使用这个对象的方法对其元素进行操作,或者使用标准数组索引语法 (使用方括号)。
new Float64Array(length);
new Float64Array(typedArray);
new Float64Array(object);
new Float64Array(buffer [, byteOffset [, length]]);
更多的语法信息和参数,参见 TypedArray.
Float64Array.BYTES_PER_ELEMENT
在
Float64Array的情况下返回8。
Float64Array.prototype.length
。Float64Array.name
Float64Array
类型的情况下为:"Float64Array"。Float64Array.prototype
Float64Array.from()
Array.from()
。Float64Array.of()
Array.of()
。Float64Array
属性所有的Float64Array对象都
继承自 %TypedArray%.prototype
。
Float64Array.prototype.constructor
Float64Array
默认的构造函数。Float64Array.prototype.buffer
只读 Float64Array引用的
ArrayBuffer
。构造时已固定,所以是只读的。Float64Array.prototype.byteLength
只读 Float64Array的
ArrayBuffer
开头开始的
长度 (以字节为单位) 。构造时已固定,所以是只读的。Float64Array.prototype.byteOffset
只读 Float64Array的
ArrayBuffer
开头开始的偏移量
(以字节为单位) 。构造时已固定,所以是只读的。Float64Array.prototype.length
只读 Float64Array中的元素个数
。构造时已固定,所以是只读的。Float64Array.prototype.copyWithin()
Array.prototype.copyWithin()
。Float64Array.prototype.entries()
返回一个包含数组中每个元素键值对的数组遍历器对象
。参见Array.prototype.entries()
。Float64Array.prototype.every()
Array.prototype.every()
。Float64Array.prototype.fill()
Array.prototype.fill()
。Float64Array.prototype.filter()
Array.prototype.filter()
。Float64Array.prototype.find()
Array.prototype.find()
。Float64Array.prototype.findIndex()
Array.prototype.findIndex()
。Float64Array.prototype.forEach()
Array.prototype.forEach()
。Float64Array.prototype.includes()
返回true
或 false
。参见Array.prototype.includes()
。Float64Array.prototype.indexOf()
Array.prototype.indexOf()
。Float64Array.prototype.join()
Array.prototype.join()
。Float64Array.prototype.keys()
返回一个包含数组中所有索引的数组遍历器
。 参见Array.prototype.keys()
。Float64Array.prototype.lastIndexOf()
Array.prototype.lastIndexOf()
。Float64Array.prototype.map()
Array.prototype.map()
。Float64Array.prototype.move()
未实现Float64Array.prototype.copyWithin()
以前的一个非标准版本。Float64Array.prototype.reduce()
Array.prototype.reduce()
。Float64Array.prototype.reduceRight()
Array.prototype.reduceRight()
。Float64Array.prototype.reverse()
Array.prototype.reverse()
。Float64Array.prototype.set()
Float64Array.prototype.slice()
Array.prototype.slice()
。Float64Array.prototype.some()
Array.prototype.some()
。Float64Array.prototype.sort()
Array.prototype.sort()
。Float64Array.prototype.subarray()
Float64Array
。Float64Array.prototype.values()
Array.prototype.values()
。Float64Array.prototype.toLocaleString()
Array.prototype.toLocaleString()
。Float64Array.prototype.toString()
Array.prototype.toString()
。Float64Array.prototype[@@iterator]()
// 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);
?规范 | ?状态 | ?注释 |
---|---|---|
Typed Array Specification | Obsolete | 被ECMAScript 6取代。 |
ECMAScript 2015 (6th Edition, ECMA-262) TypedArray constructors |
Standard | 在ECMA中初始定义,另外规定需要使用new。 |
ECMAScript Latest Draft (ECMA-262) TypedArray constructors |
Draft |
特性 | Chrome | Firefox (Gecko) | Internet Explorer | Opera | Safari |
---|---|---|---|---|---|
基础支持 | 7.0 | 4.0 (2) | 10 | 11.6 | 5.1 |
需要用new |
? | 44 (44) | ? | ? | ? |
特性 | Android | Chrome for Android | Firefox Mobile (Gecko) | IE Mobile | Opera Mobile | Safari Mobile |
---|---|---|---|---|---|---|
基础支持 | 4.0 | (Yes) | 4.0 (2) | 10 | 11.6 | 4.2 |
需要用new |
? | ? | 44.0 (44) | ? | ? | ? |
从ECMAScript 2015 (ES6)开始, Float32Array
构造函数需要用一个new
操作符来构造。现在直接把Float32Array构造函数当函数调用而不使用new,会抛出一个
TypeError
。
var dv = Float64Array([1, 2, 3]);
// TypeError: calling a builtin Float64Array constructor
// 不允许不使用new
var dv = new Float64Array([1, 2, 3]);