TE
科技回声
首页24小时热榜最新最佳问答展示工作
GitHubTwitter
首页

科技回声

基于 Next.js 构建的科技新闻平台,提供全球科技新闻和讨论内容。

GitHubTwitter

首页

首页最新最佳问答展示工作

资源链接

HackerNews API原版 HackerNewsNext.js

© 2025 科技回声. 版权所有。

Examples of everything new in ECMAScript 2016, 2017, and 2018

361 点作者 node-bayarea大约 7 年前

18 条评论

oneeyedpigeon大约 7 年前
&gt; Trivia: the JavaScript spec people wanted to name it contains, but this was apparently already used by Mootools so they used includes<p>That sounds ... unfortunate, to say the least. Why is the language spec. beholden to one framework written in that language? Doesn&#x27;t mootools [1] check first for functions it might be overriding?<p>&gt; Emojis and other double-byte chars are represented using multiple bytes of unicode. So padStart and padEnd might not work as expected!<p>It&#x27;s a shame this isn&#x27;t followed up on. What&#x27;s the solution? Only use ASCII? Don&#x27;t use padStart&#x2F;padEnd? Does anyone know anything about monospace fonts and any guarantees they make wrt. unicode?<p>[1] <a href="https:&#x2F;&#x2F;mootools.net&#x2F;core&#x2F;docs&#x2F;1.5.2&#x2F;Types&#x2F;Array#Array:contains" rel="nofollow">https:&#x2F;&#x2F;mootools.net&#x2F;core&#x2F;docs&#x2F;1.5.2&#x2F;Types&#x2F;Array#Array:conta...</a>
评论 #16753921 未加载
评论 #16754467 未加载
评论 #16753876 未加载
评论 #16753917 未加载
评论 #16757546 未加载
hackcasual大约 7 年前
Don&#x27;t get too excited for SharedArrayBuffer. Every major browser disabled it to help mitigate spectre, and there&#x27;s no current road map for re-enablement.
评论 #16750588 未加载
评论 #16750741 未加载
评论 #16750536 未加载
评论 #16750002 未加载
评论 #16752925 未加载
keyle大约 7 年前
I&#x27;m surprised we don&#x27;t have the &#x27;safe navigation operator&#x27; yet in Javascript.<p>It would be very useful, especially in templating engines, complex VueJS views etc.<p><a href="https:&#x2F;&#x2F;en.wikipedia.org&#x2F;wiki&#x2F;Safe_navigation_operator" rel="nofollow">https:&#x2F;&#x2F;en.wikipedia.org&#x2F;wiki&#x2F;Safe_navigation_operator</a>
评论 #16750762 未加载
Avery3R大约 7 年前
Gigantic sticky header and footer and a huge font size? You can barely fit a single paragraph on the page, this is probably one of the worst website designs that I&#x27;ve ever seen.
评论 #16751041 未加载
评论 #16753641 未加载
评论 #16755385 未加载
评论 #16759823 未加载
评论 #16751202 未加载
Flimm大约 7 年前
&gt; This is because ️ is two bytes long (&#x27;\u2764\uFE0F&#x27; )!<p>No, that&#x27;s not bytes. You&#x27;re counting code points. Because of the way Javascript works, it can&#x27;t accept code points greater than U+FFFF, so it has to use surrogate pairs.
评论 #16749455 未加载
ridiculous_fish大约 7 年前
The ECMAScript spec is weird. One example: in ES5 RegExp.prototype was itself a RegExp, in ES6 it became not a RegExp but just an Object, and in ES7 it stayed an Object but all of the RegExp.prototype methods have to specially check if `this` is RegExp.prototype, thereby pretending to be a RegExp, without actually being one.<p>Why does the spec have this churn?
评论 #16754092 未加载
mrtksn大约 7 年前
That’s nice, lately I start forgetting what’s ECMAScript and what’s Babel&#x2F;Webpack feature.<p>Sometimes it’s nice to have a refresh.
elmigranto大约 7 年前
Can someone please explain why for…of needed to be specialized for its async form?<p>I get why async generators &amp; iterators won&#x27;t work with plain for…of, but don&#x27;t get why following is invalid:<p><pre><code> for (const i of [1, 2, 3]) await getThingAtIndex(i); </code></pre> The very last example in the article uses similar code, but I feel iterating over array of promises misses the point (as opposed to actually receiving async iterator with `async next () {…}` via `Symbol.iterator`).<p>Or am I missing something here? Thanks.
评论 #16750921 未加载
评论 #16754758 未加载
jaequery大约 7 年前
i personally think javascript ECMAScript committee needs to take a break and chill for a bit. they are changing too fast. it&#x27;s to the point one forgets if a certain new syntax is available in the whatever version they are and need to check the manual several times. it was fine from es5, 6,7, but if this keeps up at this rate, it&#x27;s getting too much.
评论 #16752684 未加载
评论 #16753603 未加载
评论 #16757160 未加载
kristiandupont大约 7 年前
I really don&#x27;t understand the need for the infix exponentiation operator. Maybe it&#x27;s because I just don&#x27;t do calculation heavy JS code but it seems like nothing but a clever little trick you can impress colleagues with. I would hate for JS to evolve towards needing something like <a href="https:&#x2F;&#x2F;www.ozonehouse.com&#x2F;mark&#x2F;periodic&#x2F;" rel="nofollow">https:&#x2F;&#x2F;www.ozonehouse.com&#x2F;mark&#x2F;periodic&#x2F;</a>
kuon大约 7 年前
I see JS becoming more and more complex, while elm becomes more and more simple, yet it can do a lot.
collyw大约 7 年前
Fixed header and footer wastes enough screen space on a laptop that it makes it annoying to read.
dmix大约 7 年前
&gt; Until now, if we want to share data between the main JS thread and web-workers, we had to copy the data and send it to the other thread using postMessage . Not anymore!<p>This would have been great for a complex Chrome web extension (Gmail &quot;AI&quot; plugin) I developed previously. It relied on quite a significant amount of postMessage&#x27;ing back&#x2F;forth where I had to create a hand-built queue system (on both ends) with redundancy and debugging. And even then I still had a endless series of race conditions and silently failing bugs that were difficult to debug :&#x2F;
collyw大约 7 年前
Question from a backend dev who need to do some JavaScript from time to time.<p>What version should I use? With backend stuff I am usually responsible for installing the versions of the code &#x2F; language &#x2F; libraries that I use. With browsers what can I reasonably expect users to have in their browser?
评论 #16753847 未加载
评论 #16753837 未加载
评论 #16754270 未加载
评论 #16755452 未加载
ceruleus大约 7 年前
In the ES2018 section, there are 2 #8s.
wotbbcicxinu大约 7 年前
Thanks. I didnt realize some of those 2018 examples just got in. Im really enjoying the object helpers
ransom1538大约 7 年前
Nice almost as good as PHP. I loved the whole get keys segment.
评论 #16751671 未加载
EtDybNuvCu大约 7 年前
I am pleased to see that features from E continue to be smuggled into ES, like finally-style asynchronous cleanup and template literal enhancements.<p>Edit: Downvotes can&#x27;t undo our improvements to ES. We will drag JavaScript and its users, kicking and screaming, to a capability-secure future.
评论 #16751541 未加载
评论 #16751212 未加载
评论 #16760349 未加载