Live data from Hacker News

New Features in ES2019

javascript.christmas

1–10 of 123 posts

Re: New Features in ES2019

#3
I don’t mean to hate on ECMAScript, but is anyone else slightly surprised these features weren’t in earlier?

Like I wonder how many bugs were introduced because the developer didn’t realize Array.sort() was unstable.

Re: New Features in ES2019

#5
post #3

I don’t mean to hate on ECMAScript, but is anyone else slightly surprised these features weren’t in earlier? Like I wonder how many bugs were introduced because the developer didn’t realize Array.sort() was unstable.

Another sort() quirk that catches people out is not realising it uses string comparison by default

    [1,2,10].sort()
= [1,10,2]

Re: New Features in ES2019

#6
post #5
post #3

I don’t mean to hate on ECMAScript, but is anyone else slightly surprised these features weren’t in earlier? Like I wonder how many bugs were introduced because the developer didn’t realize Array.sort() was unstable.

Another sort() quirk that catches people out is not realising it uses string comparison by default [1,2,10].sort() = [1,10,2]

js never ceases to amaze me... O_o

Re: New Features in ES2019

#7
post #5
post #3

I don’t mean to hate on ECMAScript, but is anyone else slightly surprised these features weren’t in earlier? Like I wonder how many bugs were introduced because the developer didn’t realize Array.sort() was unstable.

Another sort() quirk that catches people out is not realising it uses string comparison by default [1,2,10].sort() = [1,10,2]

> is not realising it uses string comparison by default

Hell, really?? That's gross.

As for the parent's comment about a dev "not realising array.sort() was unstable", the dev should know his tools. I can't see anyway why a stable sort is better, I've never sorted on x then sorted on x, you just sort on x & y.

Re: New Features in ES2019

#8

I wonder what kind of shenanigans you could do with Function.toString(). It'd be even better if they had Function.toAST().

In MS's dialect of jscript you could get the function body as a string. That would have been useful in a few cases I'd worked on.

Re: New Features in ES2019

#9

I wonder what kind of shenanigans you could do with Function.toString(). It'd be even better if they had Function.toAST().

First thing I thought about was runtime monkeypatching - while this could be done via simple string replacement during build time (via webpack/rollup etc plugins) now you will be able to do it runtime as well.

Re: New Features in ES2019

#10
post #5
post #3

I don’t mean to hate on ECMAScript, but is anyone else slightly surprised these features weren’t in earlier? Like I wonder how many bugs were introduced because the developer didn’t realize Array.sort() was unstable.

Another sort() quirk that catches people out is not realising it uses string comparison by default [1,2,10].sort() = [1,10,2]

It’s the curse of the optional arguments. Same thing with parsing numbers where the second argument magically specifies the base.

If the comparison function argument was mandatory in sort() this wouldn’t be a problem.

Post reply on HN