New JavaScript features in Node.js v12:
Array#{flat,flatMap}
class fields
globalThis
Intl.{ListFormat,Locale,RelativeTimeFormat}
Object.fromEntries
stable Array#sort
String#matchAll
Symbol#description
well-formed JSON.stringify
-
Show this thread
-
-
Replying to @helloworlddan @mathias
Array#sort takes an array as an argument, and returns that same object sorted, rather than a new object, in effect doing sorting via side-effect. The new sort returns a new array, making it far more useful for immutable programming.
2 replies 0 retweets 3 likes -
Replying to @kurt_cagle @helloworlddan
That’s not true, Kurt. The sort still happens in-place, as before. The difference is that with stable sort, elements that compare “equal” preserve their original order. See https://v8.dev/blog/array-sort for details.
1 reply 0 retweets 10 likes -
Replying to @mathias @kurt_cagle
So before, two elements were swapped if they compareed equal?
1 reply 0 retweets 0 likes -
*compared
1 reply 0 retweets 0 likes
Mathias Bynens Retweeted Mathias Bynens
Previously, “equal” elements could occur in unpredictable order in the output array. Stability was not guaranteed by the spec or by implementations. See https://twitter.com/mathias/status/1036626116654637057 … for some more background.
Mathias Bynens added,
Previously, V8 used an unstable QuickSort for arrays with more than 10 elements. Now, we use the stable TimSort algorithm.
Demo: https://mathiasbynens.be/demo/sort-stability … pic.twitter.com/zrynE48Vcp-
-
Thanks. Twitter will use this to make your timeline better. UndoUndo
-
Loading seems to be taking a while.
Twitter may be over capacity or experiencing a momentary hiccup. Try again or visit Twitter Status for more information.
JavaScript, HTML, CSS, HTTP, performance, security, Bash, Unicode, i18n, macOS.