size(x: unknown): array
Size of an N-D array.
Determines the size of an N-dimensional array, where a number is treated as a 1x1 array, a 1-D array as 1xN, and a matrix as MxN. It handles strings by returning their length as 1xN.
Size of a 4D array
Size of a 4D array
import { assertEquals } from "jsr:@std/assert"; assertEquals(size([[[[5, 6, 5], [7, 8, -1]]]]), [1, 1, 2, 3]);
Size of a 2D matrix
Size of a 2D matrix
import { assertEquals } from "jsr:@std/assert"; assertEquals(size([[3, 2, 7], [4, 5, 6]]), [2, 3]);
Size of a 1D array
Size of a 1D array
import { assertEquals } from "jsr:@std/assert"; assertEquals(size([5, 4, 4]), [1, 3]);
Size of a string
Size of a string
import { assertEquals } from "jsr:@std/assert"; assertEquals(size('ubique'), [1, 6]);
An array of dimensions representing the size of the input.