I will concede that I failed to write a function definition, thanks for catching that. I guess I unintentionally refactored the outer function away because development brain took over? Sloppy on my part, regardless.
The point was that modern JS is more convenient to use: Const/let, arrows, classes, proxies, async/await, generators, destructuring, default/rest/spread parameters, etc.
Even if you discard const/let/arrows as merely syntactic improvements (which they are not), you should not ignore the others - unless of course they are all syntactic improvements with added features at which point "syntax" lost its "meaning".
In fact, your example suffers from the same problem: It sorts in descending order (20,10,2,1) instead of ascending (1,2,10,20).
Telling JS to use a TypedArray [Int8,...,BigInt64] instead can solve this without remembering and providing your own comparator:
Float64Array.from([1,2,10,20]).sort(); //[1,2,10,20]
You also now have classes, proxies, async/await, generators, destructuring, default/rest/spread parameters, ...
Add typing via jsdocs or TypeScript and - like the parent comment said - "it's really nice".
Often people mistake JS for a mere DOM manipulation language and think of
instead of what it has become today.I still hate it though for sorting arrays with only number types lexically: