MediumType Coercion💻 Output Question

String spread — unicode-safe character split

💡

Hint

[...str] splits a string into characters correctly, even for multi-byte Unicode (unlike split("")).

What does this output?

const str = 'hello';
const chars = [...str];
console.log(chars.length);
console.log(chars.reverse().join(''));

Correct Output

5
olleh

Why this output?

Explanation: Strings are iterable — spread gives an array of characters. reverse() and join() produce the reversed string.

Key Insight: [...str] splits a string into characters correctly, even for multi-byte Unicode (unlike split("")).

More Type Coercion Output Questions

EasyPlus operator: string concat vs numeric addMediumLoose equality edge cases with nullEasytypeof for common valuesMediumTruthy and falsy — empty array and object are truthy

Practice predicting output live →

66 output questions with instant feedback

💻 Try Output Quiz