Set Splits Strings
Examples of JavaScript's Set
usually include an array as the argument:
const arraySet = new Set([1, 2, 3, 4, 5]);
However, the Set
constructor also accepts a string, splitting it into a set for you:
const text = 'India';
const stringSet = new Set(text); // Set ['I', 'n', 'd', 'i', 'a']
Enjoy those extra keystrokes!
Tweet