Skip to main content

resize

Resize the array.

[].resize(10); // length is now 10
[1,2,3].resize(2); // truncating the size to 2

Syntax

resize(newSize)

Returns

A copy of the array.

Notes

  • Modifies the array in-place.
  • The size argument gets coerced to a uint
  • If the new size is larger than the current size, then it will fill the new values with undefined values.
  • If the new size is smaller than the current size, then it will remove all elements that exceed the size.