string.splitAt()

Split a String at a provided index.

Signature

splitAt(index: Number) => [String, String]

Description

Splits the calling String at a zero-based offset index.

The calling String isn’t changed.

Parameters

Parameter Type Required Description

index

Number

true

Zero-based offset index to split the calling String at.

Return value

Type Description

Array<String>

Array of Strings resulting from the split.

Examples

'foobar'.splitAt(3)
[
  "foo",
  "bar"
]
\