9 ms·
New ES2019 JavaScript features
- dlojudice 7y agoJS is going to be so different in 2019 that I'm expecting a revised version of "The Good Parts"[1] [1] https://www.amazon.com/JavaScript-Good-Parts-Douglas-Crockford/dp/0596517742 https://www.amazon.com/JavaScript-Good-Parts-Douglas-Crockfo...
- eropple 7y agoThat book is of an era and hasn't been particularly relevant in quite awhile. The rise of classes as prototype sugar made a lot of the navel-gazing of object creation mostly moot. The rise of rigorous linting took care of the rest. TypeScript helped a lot, too.
- Roboprog 7y agoSome of us consider “class” a bad thing. I would rather work in a language/style that draws its inspiration from Scheme than Simula 67. Too bad more places are picking up TypeScript rather than ClosureScript.
- orangecat 7y agoI would rather work in a language/style that draws its inspiration from Scheme than Simula 67. Then you should push for WebAssembly improvements so you can use whatever language you want. As long as JavaScript is a de facto requirement for web development it needs to be as approachable as possible to a wide developer audience, and that means looking more like Java than Lisp.
- BigJono 7y agoOr we could've considered it an opportunity to move people away from classical inheritance and towards something that's conceptually much simpler? (which both prototypal inheritance and functional programming are)
- jcadam 7y ago> and that means looking more like Java than Lisp. No. (No (No (No (No (No)))))
- nine_k 7y agoClasses are fine! Inheritance isn't. You can mostly avoid using it, though. JS lacks homoiconicity and thus can't have a lot of nice things a Lisp dialect would, notably macros. With what we've got, I have more hope on JS eventually migrating towards a (more) statically typed language with ML influence; typescript sort of leans towards it, slowly.
- sli 7y agoYou're right about Lisp features, but CLJS macros are kind of bad at the moment. I have a fairly simple macro that works just fine in Clojure but does not compile in ClojureScript and I can't figure out why. It's probably a side-effect of how macros are handled in CLJS (they're part of a different compilation stage and must be written in CLJ or CLJC, hence :require-macros instead of just :require). If you're looking for an ML, check out ReasonML. It's really quite good, its output is quite good (and hotfix friendly), and its type system is far better than TypeScript's will ever be. Mostly because TS wants to stay close to JS. Too close, in my opinion.
- eropple 7y agoYou can consider it a bad thing, but 1) it's a really thin layer on top of prototypical inheritance, 2) it makes JavaScript more accessible to people who are used to conventional styles of language, and 3) it won, indisputably. ClojureScript didn't win, and never had a chance to win, because it's written for the small minority of Clojure people. It wasn't written for the overwhelming majority of developers. TypeScript was. So sorry that the existence of those day-to-day programmers puts a crimp in your utopia, but, enh. Personally, I'm glad we have tools to make it easier to write libraries to help that majority be more productive and to make their code safer and more correct!
- sli 7y agoIt really is a shame because ClojureScript is an absolute joy to work with. TypeScript and Javascript feel so incredibly tedious to write after using CLJS for a few months. I would really love to move into PureScript as well, but I haven't quite wrapped my arms around Haskell as a whole, yet. So maybe I should tip my toes back into Elm for a bit.
- jcadam 7y agoI do not use the 'class' keyword in Javascript and I never will. I mean, I don't like using it in Java either, but it isn't really optional there...
- stevula 7y agoNot optional for React devs. Well... maybe now with hooks.
- baron816 7y agoWhy is the pipeline operator mentioned here? That’s definitely not ES2019.
- SSchick 7y agoYea, I was thinking the same, it's not even on https://github.com/tc39/proposals https://github.com/tc39/proposals
- lhorie 7y agoStage 1 proposals were moved to a separate page, presumably to reduce clutter https://github.com/tc39/proposals/blob/master/stage-1-proposals.md https://github.com/tc39/proposals/blob/master/stage-1-propos...
- randallsquared 7y agoThis seems like a better guide to actual ES2019: https://medium.com/@selvaganesh93/javascript-whats-new-in-ecmascript-2019-es2019-es10-35210c6e7f4b https://medium.com/@selvaganesh93/javascript-whats-new-in-ec...
- lhorie 7y agoFYI, the ES2019 spec has been published[1] already and optional chaining and pipeline operator are not in it. If you want to know what's new in ES2019, look no further than the [Introduction](https://www.ecma-international.org/ecma-262/10.0/index.html#sec-intro https://www.ecma-international.org/ecma-262/10.0/index.html#...) section in the spec. > This specification, the 10th edition, introduces a few new built-in functions: flat and flatMap on Array.prototype for flattening arrays, Object.fromEntries for directly turning the return value of Object.entries into a new Object, and trimStart and trimEnd on String.prototype as better-named alternatives to the widely implemented but non-standard String.prototype.trimLeft and trimRight built-ins. In addition, this specification includes a few minor updates to syntax and semantics. Updated syntax includes optional catch binding parameters and allowing U+2028 (LINE SEPARATOR) and U+2029 (PARAGRAPH SEPARATOR) in string literals to align with JSON. Other updates include requiring that Array.prototype.sort be a stable sort, requiring that JSON.stringify return well-formed UTF-8 regardless of input, and clarifying Function.prototype.toString by requiring that it either return the corresponding original source text or a standard placeholder. [1] https://www.ecma-international.org/ecma-262/10.0/index.html https://www.ecma-international.org/ecma-262/10.0/index.html
- robotstate 7y agoOf course the two features I was most excited about aren't in the actual spec...
- STRiDEX 7y agoI always use http://node.green http://node.green because it also tells me if I can use it yet/soon.
- zaro 7y agoThanks. I've wondered recently how to check what is supported in node.
- Roboprog 7y agoThanks for links to accurate information, those who posted TL;DR - most of what is added in 2019 I can already do with Ramda.js, and it works in IE11, as well. Pity about the Ruby / Groovy style dot-condition-chaining NOT being in the 2019 features, though.
- atonse 7y agoAs a former C# dev, I’m excited about the optionals. As a current elixir dev, VERY excited about the pipe operator.
- nojvek 7y agoChaining operator is likely to land. V8 has optional support for it and Babel has some plugins. Pipeline operator has lots of quirks and syntax bikeshedding. I don’t think it may land. Especially when you can make your own pipe(x,y,z) function quite easily. Just a guess though.
- crooked-v 7y agoThe pipe operator is the key thing I'm really looking forward to as a general quality of life improvement.
- Bjartr 7y agoWait, trimLeft/trimRight has different semantics from trimStart/trimEnd in RTL languages. So it has to be more than a simple alias, right?
- lioeters 7y agoI checked on MDN: "The trimStart() method removes whitespace from the beginning of a string. trimLeft() is an alias of this method." https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/trimStart https://developer.mozilla.org/en-US/docs/Web/JavaScript/Refe... I suspect that trimLeft was misnamed, since its "left" didn't take into account RTL - it just meant start of string.
- a13n 7y agoSuper duper excited about optional chaining! One thing I miss from Objective-C that I wish JS would add is the `?:` operator – basically a shortened version of the ternary operator.
- saagarjha 7y agoI think that's a GCC C extension, not an Objective-C feature.
- a13n 7y agoSure, I still miss it from Objective-C :P
- strbean 7y agoHow would this differ from the idiomatic "x || y"? Just s/non-zero/truthy
- deleted 7y ago[deleted]
- nojvek 7y ago|| short circuits on falsey. 0, “”, false, null, undefined ?? Short circuits on nullish. Only null and undefined.
- rmrfrmrf 7y agoOptional chaining is moving through committee along with the "nullish coalescing operator" represented as `??`, which works like `||` except only falls through with `null` and `undefined`.
- kamyarg 7y agoDo you mean true ? console.log("foo") : console.log("bar") ? This is already there: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Conditional_Operator https://developer.mozilla.org/en-US/docs/Web/JavaScript/Refe...
- hpen 7y agowoooh optional chaining!
- rkwz 7y agoI wish there was more focus on increasing the surface area of the standard library instead of more language features like Golang
- RobertKerans 7y agoThis is a very minor frustration, and I'm screaming into the abyss, but when searching for JavaScript topics, blogposts from LogRocket pretty often come up top of the search rankings, above more authoritative sources. Often under slightly misleading titles (such as this one) that seem chosen to capitalise on common search terms, or else the articles are packed with keywords. Sometimes mildly useful but mostly they're shallow and not particularly contentful, and LogRocket seem to absolutely churn them out. Seems to have gone down slightly since moving from Medium to Hosted WP, but not much. Nothing doing, it's just SEO and getting the name "LogRocket" in front of more eyeballs, but just...urrgh
- 11235813213455 7y ago> pipeline operator no thanks, I don't think it's an interesting feature, there are alternatives (chaining, promises, ..) to avoid the cost of this new syntax Other proposals I'm more excited about: - https://github.com/tc39/proposal-iterator-helpers https://github.com/tc39/proposal-iterator-helpers - https://github.com/tc39/proposal-slice-notation/ https://github.com/tc39/proposal-slice-notation/ (and https://github.com/tc39/proposal-slice-notation/pull/32 https://github.com/tc39/proposal-slice-notation/pull/32)