A code unit is the basic component used by a character encoding system (such as UTF-8 or UTF-16). A character encoding system uses one or more code units to encode a Unicode code point.
For example, characters with diacritics such as accents can sometimes be represented using two Unicode code points:
const myString = "\u006E\u0303"; console.log(myString); // ñ console.log(myString.length); // 2
Also, since not all of the code points defined by Unicode fit into 16 bits, many Unicode code points are encoded as a pair of UTF-16 code units, which is called a surrogate pair:
const face = "🥵"; console.log(face.length); // 2
const face = "🥵"; console.log(face.codePointAt(0)); // 129397