Uche Eke definitely. It’s more about succinctness in es2015 syntax. An important property of this approach is that item order is preserved. Also true in Array.from(new Set(arr)).
Apparently, modern JavaScript is almost, but not quite, entirely unlike what I once knew as “DHTML”. It looks like some weird kind of FooML with curly brace syntax.
Stanislav Sinyagin: I’m pretty sure there was once a kludge to marry Perl to browsers. It was called “PerlScript”, and it was in some way related to “VBScript”. I have forgotten what the relation was.
John Hardy Turnbull delenda est: Once upon a time, I managed code reuse with “frames” and built dynamic user interfaces with “layers”. Apparently, both of these bleeding-edge inventions have become obsolete already.
Yes layers died years ago (I hate to break it to you but Netscape navigator is dead too). CSS grew powerful enough to tackle all those use cases. Iframes are still in use.
I thought this had been around for a while developer.mozilla.org – Set
LikeLike
Uche Eke definitely. It’s more about succinctness in es2015 syntax. An important property of this approach is that item order is preserved. Also true in Array.from(new Set(arr)).
LikeLike
Does this work with nested objects … well it kinda does … whoa. Uche Eke nice.
LikeLike
Do JavaScript’s objects and sets retain element order like Ruby’s?
LikeLike
I can do it in Perl in no time)
LikeLike
This is just an array to set to array conjugation. Andres Soolo I’m guessing sets are hash and not tree based, so probably no.
LikeLike
Deen Abiola: Actually, the specification seems to suggest sets are supposed to preserve insertion order.
LikeLike
The set constructor returns an iterable which preserves the original insertion order.
LikeLike
Apparently, modern JavaScript is almost, but not quite, entirely unlike what I once knew as “DHTML”. It looks like some weird kind of FooML with curly brace syntax.
LikeLike
Stanislav Sinyagin: I’m pretty sure there was once a kludge to marry Perl to browsers. It was called “PerlScript”, and it was in some way related to “VBScript”. I have forgotten what the relation was.
LikeLike
Andres Soolo yes it’s called ecmascript 2015 and it’s got several neat tricks that eliminate significant amounts of code.
LikeLike
John Hardy Turnbull delenda est: Once upon a time, I managed code reuse with “frames” and built dynamic user interfaces with “layers”. Apparently, both of these bleeding-edge inventions have become obsolete already.
LikeLike
Yes layers died years ago (I hate to break it to you but Netscape navigator is dead too). CSS grew powerful enough to tackle all those use cases. Iframes are still in use.
LikeLike
Andres Soolo It looks like I misread your question as is it an ordered set? Preserving insertion order actually agrees with my comment.
LikeLike