The NDArray
Every value in numpy-ts is anNDArray — a multidimensional, homogeneously-typed array backed by a JavaScript TypedArray. If you have used NumPy in Python, you already know the mental model: shape, dtype, strides, and element-wise operations.
Creating arrays from JavaScript data
Usearray() to create an NDArray from nested JavaScript arrays or a flat list:
NDArray properties
Every NDArray exposes the same set of descriptive properties you would find in NumPy:The T property — transposing
The T property returns a transposed view of the array. No data is copied; the view shares the same underlying buffer:
T returns a view, modifying the transpose also modifies the original:
Flags and views
Theflags property tells you about the memory layout:
base property indicates whether an array is a view of another array:
Inspecting arrays
toString()
Returns a summary string with shape and dtype:
array2string()
For NumPy-style formatted output, use the array2string function:
array_repr() and array_str()
Converting back to JavaScript
toArray()
Converts the NDArray into a nested JavaScript array matching the shape:
tolist()
Alias for toArray(). Provided for NumPy API compatibility:
item()
Extract a single scalar from a size-1 array:
Accessing the raw typed array
Thedata property gives you direct access to the underlying TypedArray:
Iteration
NDArrays implement the JavaScript iterator protocol. For 1-D arrays, iteration yields elements. For N-D arrays, it yields (N-1)-D sub-arrays along the first axis:Method chaining
The full entry point (numpy-ts) returns NDArray objects that support method chaining, letting you write expressive pipelines:
Next steps
Data Types
Understand the 13 supported dtypes and type promotion rules.
Slicing & Indexing
Select sub-arrays, rows, columns, and individual elements.