Skip to content

API Float64Array

Liu.Yandong.Hanks edited this page Aug 21, 2026 · 3 revisions

Float64Array

Fixed-length packed array of 64-bit floating-point numbers.

Script API Reference

Overview

Float64Array is a primitive-backed array for allocation-efficient floating-point workloads. Elements live in contiguous native double storage and can hold fractions, general numeric values, NaN, and infinities.

The length is fixed at construction. push, pop, and element deletion are unavailable; elements are read and written through numeric indexes.

var weights = new Float64Array(2);
weights[0] = 1.25;
return weights[0]; // 1.25

Warning

Indexing outside 0 to length - 1 raises a runtime error. Validate computed indexes before reading or writing.

Use Int32Array when every element is a whole number, or Array when the element type must vary or the collection has to grow.

Constructors

new Float64Array([length])

Parameters

Name Type Required Description
length number No Non-negative element count. Omitting it creates an empty array.

Returns

Float64Array — a fixed-length array whose elements start at 0.

Example

var rates = new Float64Array(4);
return rates[3]; // 0

Properties

values.length

Returns

number — the fixed element count.

Behavior

Read-only. The value never changes for a given instance.

Example

return new Float64Array(5).length; // 5

Methods

values.fill([value])

Parameters

Name Type Required Description
value number No Value written to every element. Defaults to 0.

Returns

Float64Array — this array, so calls can be chained.

Behavior

Every element is overwritten in place with the numeric conversion of the value.

Example

var rates = new Float64Array(3);
rates.fill(0.5);
return rates[1]; // 0.5

Clone this wiki locally