JS: String Operations

By Xah Lee. Date: . Last updated: .

String length

console.log("abc".length);
// 3

String length of unicode string

if the string contains emoji, see:

Substring

console.log("01234".slice(1, 3));
// 12

Index starts at 0.

Join string

Use the plus sign + to join strings.

console.log("aa" + "bb");
// aabb

String methods