length(x: ): number
Gets the length of a vector or the largest array dimension.
Returns the length of a vector or the largest dimension of a 2D array (matrix).
Length of a 1D array (vector)
Length of a 1D array (vector)
import { assertEquals } from "jsr:@std/assert"; assertEquals(length([3, 5, 6]), 3);
Length of a single element (should be 1)
Length of a single element (should be 1)
import { assertEquals } from "jsr:@std/assert"; assertEquals(length(5), 1);