TE
TechEcho
Home24h TopNewestBestAskShowJobs
GitHubTwitter
Home

TechEcho

A tech news platform built with Next.js, providing global tech news and discussions.

GitHubTwitter

Home

HomeNewestBestAskShowJobs

Resources

HackerNews APIOriginal HackerNewsNext.js

© 2025 TechEcho. All rights reserved.

What’s New in ES2019

433 pointsby davmanalmost 6 years ago

31 comments

mmartinsonalmost 6 years ago
Honest question, not meant to be inflammatory.<p>If we still need to target es5 4 years later, and transpilation is standard practice, why bother? Is the evolution of JS not directed in practice by the authors of Babel and Typescript? If no one can confidently ship this stuff for years after, what’s the incentive to even bother thinking about what is official vs a Babel supported proposal.<p>I like the idea of idiomatic JS with powerful modern features, but in practice every project I’ve seen seems to use a pretty arbitrary subset of the language, with different ideas about best practices and what the good parts are.
评论 #20564849 未加载
评论 #20564739 未加载
评论 #20564651 未加载
评论 #20565836 未加载
评论 #20564943 未加载
评论 #20564608 未加载
评论 #20566428 未加载
评论 #20564856 未加载
评论 #20566487 未加载
评论 #20566280 未加载
评论 #20570020 未加载
评论 #20564733 未加载
评论 #20565370 未加载
评论 #20568243 未加载
评论 #20565787 未加载
评论 #20569224 未加载
评论 #20570189 未加载
评论 #20569383 未加载
评论 #20566050 未加载
评论 #20564797 未加载
评论 #20568193 未加载
评论 #20567180 未加载
评论 #20568258 未加载
评论 #20564581 未加载
评论 #20566475 未加载
评论 #20565752 未加载
评论 #20566633 未加载
评论 #20567668 未加载
halfmatthalfcatalmost 6 years ago
Now if we could just get pattern matching[1] and optional chaining[2], that would really elevate things.<p>[1] <a href="https:&#x2F;&#x2F;github.com&#x2F;tc39&#x2F;proposal-pattern-matching" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;tc39&#x2F;proposal-pattern-matching</a><p>[2] <a href="https:&#x2F;&#x2F;github.com&#x2F;tc39&#x2F;proposal-optional-chaining" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;tc39&#x2F;proposal-optional-chaining</a>
评论 #20564115 未加载
评论 #20563953 未加载
评论 #20565279 未加载
评论 #20564035 未加载
评论 #20567839 未加载
评论 #20564664 未加载
评论 #20567545 未加载
评论 #20564595 未加载
评论 #20569253 未加载
评论 #20564695 未加载
ojosilvaalmost 6 years ago
A year back I dropped a proposal idea at the EcmaScript discussion list, I hope it get&#x27;s picked up sometime.<p>My idea is that `let`, `var` and `const` return the value(s) being assigned. Basically I miss being able to declare variables in the assertion part of `if` blocks that are scoped only during the `if()` block existence (including `else` blocks).<p>Something along these lines:<p><pre><code> if( let row = await db.findOne() ) { &#x2F;&#x2F; row available here } &#x2F;&#x2F; row does not exist here </code></pre> The current alternative is to declare the variable outside the `if()` block, but I believe that is inelegant and harder to read, and also requires you to start renaming variables (ie. row1, row2...) due them going over their intended scope.<p>As previous art, Golang&#x27;s:<p><pre><code> if x:=foo(); x&gt;50 { &#x2F;&#x2F; x is here } else { &#x2F;&#x2F; x is here too } &#x2F;&#x2F; x is not scoped here </code></pre> And Perl&#x27;s<p><pre><code> if( ( my $x = foo() ) &gt; 50 ) { print $x }</code></pre>
评论 #20564935 未加载
评论 #20565129 未加载
评论 #20570411 未加载
评论 #20566353 未加载
评论 #20565135 未加载
评论 #20564890 未加载
评论 #20565092 未加载
评论 #20568564 未加载
评论 #20565104 未加载
afandianalmost 6 years ago
It&#x27;s great to see JS getting some of the features of better planned languages.<p>But I&#x27;m still very nervous about some of the stuff mentioned here with regard to mutation. Taking Rust and Clojure as references, you always know for sure whether or not a call to e.g. `flat` will result in a mutation.<p>In JS, because of past experience, I&#x27;d never be completely confident that I wasn&#x27;t mutating something by mistake. I don&#x27;t know if you could retrofit features like const or mut. But, speaking personally, it might create enough safety-net to consider JS again.<p>(Maybe I&#x27;m missing an obvious feature?)
评论 #20563500 未加载
评论 #20563531 未加载
评论 #20565045 未加载
评论 #20571896 未加载
评论 #20564328 未加载
评论 #20563589 未加载
评论 #20563512 未加载
评论 #20566959 未加载
评论 #20566905 未加载
评论 #20570647 未加载
评论 #20563629 未加载
rgloveralmost 6 years ago
That array.flat() and array.flatMap() stuff is great to see. Always having to rely on lodash and friends to do that type of work. Exciting to see how JS is evolving.
评论 #20564622 未加载
评论 #20564771 未加载
评论 #20565326 未加载
评论 #20565351 未加载
评论 #20564476 未加载
chriswwwebalmost 6 years ago
A read a similar article few days ago (might be interesting too) (not mine): <a href="https:&#x2F;&#x2F;medium.com&#x2F;@selvaganesh93&#x2F;javascript-whats-new-in-ecmascript-2019-es2019-es10-35210c6e7f4b" rel="nofollow">https:&#x2F;&#x2F;medium.com&#x2F;@selvaganesh93&#x2F;javascript-whats-new-in-ec...</a><p>And also here is a good recap of ES 6&#x2F;7&#x2F;8&#x2F;9 (just in case you missed something) (also not mine): <a href="https:&#x2F;&#x2F;medium.com&#x2F;@madasamy&#x2F;javascript-brief-history-and-ecmascript-es6-es7-es8-features-673973394df4" rel="nofollow">https:&#x2F;&#x2F;medium.com&#x2F;@madasamy&#x2F;javascript-brief-history-and-ec...</a>
jeffwassalmost 6 years ago
Object.fromEntries will be super useful, surprised it’s taken this long to become a native feature.
评论 #20566341 未加载
评论 #20563966 未加载
NKCSSalmost 6 years ago
Why did they create a flatMap method? What is wrong with .map(...).flat()? Can they improve the performance by combining it that much?
评论 #20564372 未加载
评论 #20563879 未加载
评论 #20563868 未加载
评论 #20563999 未加载
评论 #20565391 未加载
dawhizkidalmost 6 years ago
arr.flat(Infinity) seems like a strange decision for flattening the entire array - wouldn&#x27;t the most common number of levels to flatten an array be all levels, in which case I&#x27;d expect arr.flat() to flatten the whole array but in this case it&#x27;s just 1 level.
评论 #20571344 未加载
评论 #20568212 未加载
nameloswalmost 6 years ago
Finally, flatMap is here.<p>I really hope there could be syntactic sugar like do expression in Haskell, for in Scala, and LinQ in C# for flatMap instead of type limited version like async await.<p>Another thing is pipe operator seems to be very welcome among the proposals. There will be no awkward .pipe(map(f), tap(g)) in RxJS since then.
swalshalmost 6 years ago
Some half decent stuff in here, but I heavily disagree with changing the output of toString. That might cause problems if someone is expecting one output, but the new version creates something new. I don&#x27;t see a reason why they couldn&#x27;t have just added a new function functionCode() or something similar. It would give people the functionality they want, without destroying backwards compatibility.
评论 #20564796 未加载
ahmedfromtunisalmost 6 years ago
Can someone please point me to the rationale behind the new toString() function?
评论 #20564284 未加载
评论 #20564390 未加载
评论 #20564240 未加载
moominalmost 6 years ago
That’s a surprisingly small amount of change. I’ll leave it to others to determine if that’s a good or bad thing.
评论 #20563690 未加载
评论 #20563523 未加载
评论 #20563792 未加载
jonstaabalmost 6 years ago
Isn&#x27;t the new function string representation backwards incompatible? Having struggled with javascript&#x27;s lame error tooling I could see people actually using it in production too.
inteaalmost 6 years ago
Why are empty elements in an array allowed? oO<p>[1,2,,3]
评论 #20564077 未加载
评论 #20564230 未加载
评论 #20567169 未加载
kuonalmost 6 years ago
The part about parameter less catch reveals a lot about the philosophy of the language. For me, silencing error like this is a bad practice. You may still produce a sane error in the catch, but the design goes toward silencing things.<p>I really love languages that force you to handle errors up to the top level.
评论 #20563604 未加载
评论 #20563831 未加载
评论 #20563559 未加载
zittoalmost 6 years ago
It&#x27;s very exciting to see how JavaScript is evolving!
评论 #20564472 未加载
pier25almost 6 years ago
I feel after ES6 and async&#x2F;await in ES7 we&#x27;re getting pretty meager upgrades.<p>IMO the three features that would make a much more significant impact in front end work are:<p>- optional static types<p>- reactivity<p>- some way to solve data binding with the DOM at the native level
评论 #20569555 未加载
bitwizealmost 6 years ago
Ummm... 25^2 is 625. 15^2 is 225 (see the Object.fromEntries example). I mean, I knew JavaScript math was a bit sloppy due to the use of floating point everywhere, but I hope it&#x27;s not THAT bad...
评论 #20566196 未加载
alexluralmost 6 years ago
That Function.prototype.toString change is probably going to break some Angular.js code who relies on scanning function argument names for dependency injection.
评论 #20564712 未加载
评论 #20564277 未加载
评论 #20563877 未加载
评论 #20563876 未加载
mhdalmost 6 years ago
So, what coffeescript features are we still missing after this round?
bryanrasmussenalmost 6 years ago
I think the flatMap method is pretty solid evidence for my contention the language is really getting bloated now.
DonHopkinsalmost 6 years ago
Is that all there is that&#x27;s new? Maybe it&#x27;s a good thing that JavaScript is finally slowing down.
estomagordoalmost 6 years ago
Under symbol.description:<p>const test = Symbol(&quot;Desc&quot;);<p>testSymbol.description; &#x2F;&#x2F; &quot;Desc&quot;<p>---------<p>Should testSymbol be replaced with test?
评论 #20563689 未加载
Already__Takenalmost 6 years ago
Why does flatmap exist? What&#x27;s against `sentence.map().flat()`
john-foleyalmost 6 years ago
Hard to believe that const arr4 = [1, 2, , 4, 5]; is valid.
评论 #20564522 未加载
derefralmost 6 years ago
.
评论 #20563477 未加载
ZenPsychoalmost 6 years ago
seems like a real missed opportunity to add string.leftPad()
评论 #20563767 未加载
评论 #20563744 未加载
评论 #20563742 未加载
la12almost 6 years ago
At this point, I&#x27;m convinced that Javascript is basically a jobs creation program.<p>We go on adding fancy new syntax for little or no gain. The whole arrow function notation, for example, buys nothing new compared to the old notation of writing &quot;function(....){}&quot; other than appearing to keep up with functional fashion of the times.<p>Similarly, python which was resistant to the idea of 20 ways to do the same thing, also seems to be going in the direction of crazy things like the &quot;walrus&quot; operator which seems to be increasing the cognitive load by being a little more terse while not solving any fundamental issues.<p>Nothing wrong with functional paradigm, but extra syntax should only be added when it brings something substantial valuable to the table.<p>Also, features should be removed just as aggressively as they are added, otherwise you end up with C++ where you need less of a programmer to be able to tell what a given expression will do and more of a compiler grammar lawyer who can unmangle the legalese.
评论 #20566349 未加载
评论 #20566424 未加载
评论 #20566405 未加载
评论 #20566342 未加载
评论 #20567199 未加载
Dirlewangeralmost 6 years ago
Can we get some additions that replace the garbage one-liner `is-even`&#x2F;`is-odd` npm libraries that are a scourge?
评论 #20564705 未加载
jorangreefalmost 6 years ago
Most of this is sugar, e.g. flat() and flatMap(), out of scope for a language spec.<p>Function.toString being more accurate is helpful.<p>But real progress would be removing dangerous backtracking regular expressions in favor of RE2: <a href="https:&#x2F;&#x2F;github.com&#x2F;google&#x2F;re2&#x2F;wiki&#x2F;Syntax" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;google&#x2F;re2&#x2F;wiki&#x2F;Syntax</a>