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

科技回声

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

GitHubTwitter

首页

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

资源链接

HackerNews API原版 HackerNewsNext.js

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

What's New in JavaScript for 2019

58 点作者 reverentgeek超过 6 年前

18 条评论

westoque超过 6 年前
I might get heat for this but personally I find the JavaScript ecosystem to be a mess. There are so many changes to the language that are done aggressively which I think are done without much thought. For example, the promises API, now we also have async&#x2F;await. The module system, with require(s), then import&#x2F;export, and there&#x27;s browser JS and system JS (node), and npm and now yarn, then your build system, with webpacker, browserify, bower. Oh! You might also be interested in using new JavaScript syntax so don&#x27;t forget to use babel.<p>And the funny thing is they are teaching all these at bootcamps and the students have a hard time trying to understand the concepts with so many variations in them.<p>There is however light at the end of the tunnel which I think where TypeScript is.
评论 #18972571 未加载
评论 #18972436 未加载
评论 #18972462 未加载
评论 #18975043 未加载
评论 #18972644 未加载
评论 #18972545 未加载
评论 #18973126 未加载
评论 #18972434 未加载
评论 #18972565 未加载
评论 #18972726 未加载
评论 #18972600 未加载
评论 #18973608 未加载
评论 #18972415 未加载
Lerc超过 6 年前
I tend to agree with the article author about the use of a # (or indeed any punctuation mark) for private fields. I think it is just a personal preference thing though. Is there any publicly available discussion that shows what lead to this decision?<p>If fields in class definitions are incorporated I would like it to simultaneously make the field names in scope for any methods within the class definition.<p><pre><code> class Fish extends Vertebrate { color = &quot;blue&quot;; constructor (speed) { super(); this.speed = speed; if (speed &gt; 5) color = &quot;red&quot; &#x2F;&#x2F; does not need this.color because color is a class field. } } Fish.prototype.setColor = function (newValue) { this.color = newValue; &#x2F;&#x2F; this. is required because this function is outside the class definition. } </code></pre> Adding this feature would allow for much tidier method bodies since there is now enough information to imply this.fieldName from fieldName alone.
评论 #18972456 未加载
评论 #18972504 未加载
dsego超过 6 年前
At this point why not just have browsers run TypeScript natively? Remember the &lt;script type=&quot;text&#x2F;javascript&quot;&gt;&lt;&#x2F;script&gt;, maybe just put &lt;script type=&quot;text&#x2F;typescript&quot;&gt;&lt;&#x2F;script&gt; and be done with it.
评论 #18972667 未加载
评论 #18972572 未加载
评论 #18972553 未加载
goatlover超过 6 年前
&gt; There are a number of proposed changes to Classes, including field declarations, private methods and fields, and static methods and fields.<p>So make it look full on like traditional OOP with classes, I guess? I suppose the prototype folks lost this debate.
评论 #18972388 未加载
评论 #18972340 未加载
评论 #18972314 未加载
ape4超过 6 年前
<p><pre><code> #this_is_not_a_comment = 6;</code></pre>
评论 #18972302 未加载
评论 #18972300 未加载
评论 #18972309 未加载
sjroot超过 6 年前
The only thing that still blows my mind are the private fields and methods. I understand there has been plenty of debate about it, but have not followed the conversation. I really hope that syntax does not get finalized.
评论 #18972377 未加载
crdrost超过 6 年前
`flat` and `flatMap` are highly welcome additions for me; concatenating a bunch of lists together has historically been a very common operation for me, that right now is done best as<p><pre><code> [].concat(...arrayOfArrays) </code></pre> It is also the basis more generally for the list monad, where `.flat()` is the `join` operation and `.flatMap()` is the equivalent `bind` operation.<p>So, like, the simplest example is if you&#x27;re just getting a bunch of results from a paginated source -- you want to flatten them, and it is really nice to just have a method for that.<p>The list monad case is more interesting because it gives a syntax for list comprehensions:<p><pre><code> [ x + y for x in list1 for y in list2 if x % 2 == 0 and y % 2 == 1 ] </code></pre> becomes<p><pre><code> list1.flatMap(x =&gt; x % 2 !== 0 ? [] : list2.flatMap(y =&gt; (y % 2 == 0 ? [] : x + y)) ); </code></pre> And more theoretically this list monad is all about composing nondeterminism, where one input could produce any of N outputs: if you store all of the current possibilities as an array then flatMap is the core composition primitive.
ryanolsonx超过 6 年前
I&#x27;m _super_ excited for flat and flatMap. In working with multidimensional arrays, I&#x27;m always needing to use my own `flatten` function before returning my value. I love that this is getting native support.
评论 #18972288 未加载
ralmidani超过 6 年前
JS the language is great, and it becomes even better with TypeScript. But the ecosystem leaves a lot to be desired.<p>Having become proficient with Node&#x2F;Express&#x2F;Sequelize at Fullstack Academy and then used them for several months, I really miss Django and Django REST Framework. The ORM, serializers, effortless filtering and permissions, etc. are--with all due respect--simply unmatched in JS-Land.<p>As for the front-end, I learned and used Ember for over a year before picking up React (it was &quot;cooler&quot; and there were more jobs). So many decisions I&#x27;ve agonized over with React&#x2F;Redux were solved years ago with Ember. But the problem with Ember is its proprietary object system and its lack of momentum.<p>If I have a choice, I will be starting new projects with Django on the server-side, and Ember only when an SPA is necessary. In the past, I hesitated to use Django for templates, but the lack of a robust client-side ORM has made that option more attractive.
wtetzner超过 6 年前
&gt; Why not use private.x to refer to a private field of this, and private(that).x to refer to a private field of another object?<p>I don&#x27;t find the answer to this [1] to be particularly compelling. This actually seems like the right solution to me.<p>[1] <a href="https:&#x2F;&#x2F;github.com&#x2F;tc39&#x2F;proposal-class-fields&#x2F;blob&#x2F;master&#x2F;PRIVATE_SYNTAX_FAQ.md#why-not-use-privatex-to-refer-to-a-private-field-of-this-and-privatethatx-to-refer-to-a-private-field-of-another-object" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;tc39&#x2F;proposal-class-fields&#x2F;blob&#x2F;master&#x2F;PR...</a>
je42超过 6 年前
Followed the links of the article a bit. The document explaining the process of finding a good name (&quot;globalThis&quot;) for global is pretty cool: <a href="https:&#x2F;&#x2F;github.com&#x2F;tc39&#x2F;proposal-global&#x2F;blob&#x2F;master&#x2F;NAMING.md" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;tc39&#x2F;proposal-global&#x2F;blob&#x2F;master&#x2F;NAMING.m...</a>
elwell超过 6 年前
Yet another signal that ClojureScript was ahead of its time when it was created.
stevecalifornia超过 6 年前
If you want to make programming inaccessible to newcomers, start making special characters that inexplicably mean special things... like # means &#x27;private&#x27; when placed in front of a function.
评论 #18972832 未加载
notus超过 6 年前
The proposed globalThis seems like a hacky solution to a bad problem
评论 #18972850 未加载
rinchik超过 6 年前
so static is `static` but private is `#` ?<p>I wonder whats the reasonig behind it? `private` is already a reserved word in JS, why not just use it? <a href="https:&#x2F;&#x2F;www.w3schools.com&#x2F;js&#x2F;js_reserved.asp" rel="nofollow">https:&#x2F;&#x2F;www.w3schools.com&#x2F;js&#x2F;js_reserved.asp</a>
评论 #18972481 未加载
评论 #18972509 未加载
z3t4超过 6 年前
Noob question: What does static mean in other languages? Is it basically Foo.prototype.bar !?
评论 #18974710 未加载
ivoras超过 6 年前
Huh... why would there need to be something new for JavaScript in 2019?<p>At this point, it looks like they might as well import the Java syntax and call it &quot;JavaScript fusion&quot; and be done with it.
altmind超过 6 年前
I&#x27;m alerted that javascript tends to bloat the stdlib. Most of the features mentioned can be implmented as a external library. This is benefitial for users as they can switch the implenmentation and upgrade versions without waiting for all of their users to upgrade the runtime first.<p>The prime example of javascript unnecessary bloat is fetch api which is mere wrapper for ajax calls, was developed a while ago but still cannot be used because of lack of support in older runtimes.
评论 #18972364 未加载
评论 #18972412 未加载