JS: String Operations

By Xah Lee. Date: . Last updated: .

String length

"abc".length === 3

Note: no parenthesis after β€œlength”.

Substring

"01234".slice(1,3) === "12"

Index starts at 0.

Join String

Use the plus sign + to join strings.

("aa" + "bb") === "aabb"

String Methods

JavaScript, String