To run this program, save it as strings-and-characters.js and use Node.js:
In JavaScript, strings are sequences of UTF-16 code units. Unlike some other languages, JavaScript doesn’t have a separate “character” type. Instead, a character is represented by a string of length 1 or 2 (for surrogate pairs).
The String.prototype.codePointAt() method returns a Unicode code point value, which is equivalent to the concept of a “rune” in some other languages. The String.fromCodePoint() method creates a string from a code point value.
JavaScript’s for...of loop and the spread operator [...s] automatically handle surrogate pairs, making it easier to work with Unicode characters that are represented by two code units.
Remember that when working with Unicode in JavaScript, the length of a string might not always correspond to the number of visual characters, especially for complex scripts or emoji.