Search⌘ K

UTF-32 support

Explore how the for-of loop in JavaScript correctly processes UTF-32 Unicode characters, ensuring accurate iteration over all character sizes compared to the for-in loop. This lesson helps you understand the practical differences in character handling for better coding with Unicode data.

We'll cover the following...

Consider the following code snippet:

Node.js
let text = '\u{1F601}\u{1F43C}';
console.log( 'text: ', text );
for( let i in text ) {
console.log(text[i]);
};
console.log('-----');
for ( let c of text ) {
console.log( c );
};

Execute the above ...