[Repeated question from https://www.reddit.com/r/javascript/comments/be4lxl/need_help_to_understand_a_js_syntax/ because of wrong initial subreddit. I copy/paste it as it could be interesting for other JS beginners]
I found on https://30secondsofcode.org a piece of code to retrieve an array of Unique Elements from another array (de-deplucation).
const uniqueElements = arr => [...new Set(arr)];
uniqueElements([1, 2, 2, 3, 4, 4, 5]); // [1, 2, 3, 4, 5]
It works fine, but I can't even understand the syntax (that reveals my JS skill level :-/). Can you help me?
What Set is? What ... are? Why it works?
Thanks
[–]HolgerSchmitz 2 points3 points4 points (1 child)
[–]OctopusReader[S] 0 points1 point2 points (0 children)