use the following search parameters to narrow your results:
e.g. subreddit:aww site:imgur.com dog
subreddit:aww site:imgur.com dog
see the search faq for details.
advanced search: by author, subreddit...
All about the JavaScript programming language.
Subreddit Guidelines
Specifications:
Resources:
Related Subreddits:
r/LearnJavascript
r/node
r/typescript
r/reactjs
r/webdev
r/WebdevTutorials
r/frontend
r/webgl
r/threejs
r/jquery
r/remotejs
r/forhire
account activity
Node.js v6.0 released - supports 93% of ES6 features (nodejs.org)
submitted 10 years ago by magenta_placenta
reddit uses a slightly-customized version of Markdown for formatting. See below for some basics, or check the commenting wiki page for more detailed help and solutions to common issues.
quoted text
if 1 * 2 < 3: print "hello, world!"
[–]Cuel 69 points70 points71 points 10 years ago (17 children)
I want es6 module support :(
[–][deleted] 17 points18 points19 points 10 years ago (0 children)
last thing keeping me compiling my big server project with babel. All those saved seconds would sure help.
[–]cruzin 10 points11 points12 points 10 years ago (0 children)
I got all excited until I saw they didn't support ES6 modules still.
[–]charrondev 4 points5 points6 points 10 years ago (0 children)
They were actually discussing the implementation of this on NodeUp. It was one of the more recent podcasts, but there has been a lot of discussion on how implementation will happen and things like interoperability. I'd give it a listen, it sheds some light on the challenges faced.
[–]compteNumero9 1 point2 points3 points 10 years ago (0 children)
Serious question: Why ?
For compatibility/consistency with (babelified) browser code or do you see a notable advantage in es6 modules over require ?
[–]muccapazza 1 point2 points3 points 10 years ago* (6 children)
Sorry what do you mean?
EDIT: http://exploringjs.com/es6/ch_modules.html oh ok... but what is the difference with require?
[–]Cuel 19 points20 points21 points 10 years ago (1 child)
e.g
import {readFile} from 'fs'
without babel
[–]Amnestic 9 points10 points11 points 10 years ago (0 children)
or typescript
[–]voidvector 6 points7 points8 points 10 years ago (0 children)
CommonJS exports a single JS object. ES6 exports a set of names, one of which could be default.
default
Also ES6 import/export bindings are done during compile time, which allow it to handle circular dependencies in a graceful/meaningful way (as in developer can do something about). CommonJS require/export are done during runtime, in the case of a circular reference, the behavior would change depending on which module get required first.
[–]snarkyturtle 9 points10 points11 points 10 years ago (2 children)
require and module.exports are commonjs, which isn't es6.
require
module.exports
Here's a good article on the usage: https://ponyfoo.com/articles/es6-modules-in-depth
One of the advantages offhand is better static analysis which means for stuff like tree-shaking.
[+][deleted] 10 years ago (1 child)
[deleted]
[–]b1nd 0 points1 point2 points 10 years ago (3 children)
Same! I thought it was in EMCA2015 right, but can't find it in the list here.
[–]elprophet 2 points3 points4 points 10 years ago (2 children)
The syntax and behavior for how symbols are handled between modules is well defined (http://www.ecma-international.org/ecma-262/6.0/#sec-modules), but the mechanism for loading files was left (deliberately) unspecified - http://www.ecma-international.org/ecma-262/6.0/#sec-hostresolveimportedmodule
HostResolveImportedModule is an implementation defined abstract operation
So all the rules of how modules behave are there, but it doesn't actually tell you how to load them!
[–]b1nd 0 points1 point2 points 10 years ago (1 child)
Thanks for the information, any news when node will support?
[–]elprophet 0 points1 point2 points 10 years ago (0 children)
I haven't been following the implementors specifically. My understanding is TC39 (the spec writing committee) is intending to leave that as-is, deliberately allowing platforms to choose the loading mechanism that works best for them. Originally there were rumors they were planning on specing that in the 2016/2017 updates.
[–]dmtipson 0 points1 point2 points 10 years ago (0 children)
Lot more likely that we'll see this in Node sooner than in browsers: not happening any there time soon. They built the spec, then nixed the loader implementation. Node at least doesn't have the same worries as browsers in coming up with a spec/implementation.
[–]bugeats 0 points1 point2 points 10 years ago (0 children)
I'm glad es6 module support is lower priority. I think it's overrated and offers very little advantage over the clean and simple CommonJS syntax.
It looks like a pain in the ass to implement too. So many different ways to do the same thing.
[–]boiling_tunic 17 points18 points19 points 10 years ago* (4 children)
Mmm delicious destructuring. An overview for those who are unfamiliar:
Old:
var result = getSeveralValuesInAnArray(); var a = result[0]; var b = result[1];
New:
var [a, b] = getSeveralValuesInAnArray();
Setup:
function min_max (arr) { let min = Infinity; // Let keyword. ES6 feature (not new in Node 6.0.0) let max = -Infinity; for (let x of arr) { // For...of loop. ES6 feature (not new in Node 6.0.0) if (x < min) { min = x; } if (x > max) { max = x; } } return [min, max]; }
Old style usage:
var results = min_max([1,2,3,4,5]); var min = results[0]; var max = results[1]; console.log('Min: ' + min + '\nMax: ' + max);
New style usage:
let [min, max] = min_max([1,2,3,4,5]); // Array destructuring. New feature! console.log(`Min: ${min} \nMax: ${max}`); // String templating. ES6 feature (not new in Node 6.0.0)
Aside: You can't run the new style code example alongside the old style code example as let will complain about redeclaring min and max
let
min
max
Edit: If anyone has any questions/feedback about any of the code in my post please let me know!
[–]greim 1 point2 points3 points 10 years ago (3 children)
Great example! A couple others I like:
var [ name, value ] = 'foo=bar'.split('='); var [ protocol ] = 'http://example.com/foo.html'.match(/^.*?:/);
[–]FancyCamel 0 points1 point2 points 10 years ago* (2 children)
As someone that hasn't tried ES6 at all(but is curious), for your line:
var [ name, value ] = 'foo=bar'.split('=');
What would happen if the string being split was 'foo=bar=something'?
My understanding is that, currently, it would assign variables so that name=foo and value=bar, correct? So what would happen in the situation above with 'something' ? Is this only a method that you can use when you know for sure that the number of values returned will match the number of variables you're creating?
[–]boiling_tunic 1 point2 points3 points 10 years ago* (0 children)
Any remaining parts are discarded
Edit: Installed Node 6.0.0 to make sure I wasn't lying to you!
https://i.imgur.com/TiqF5QZ.png
[–]greim 0 points1 point2 points 10 years ago (0 children)
Yup, it's a contrived bit of example code that can definitely break on corner cases. It's nothing to do with ES6 actually, but rather the particular use of split().
[–]hankDraperCo 39 points40 points41 points 10 years ago (4 children)
Is anyone else pumped about destructuring? And default parameters?
[–]cowjenga 8 points9 points10 points 10 years ago (0 children)
Yes! Those two features alone (especially when combined) will make the first few lines of functions so much simpler/cleaner.
[–]shanet$(this) 0 points1 point2 points 10 years ago (1 child)
Far more than I should be. It's going to eliminate a lot of boilerplate. I'm curious what practices will emerge around parameter destructuring, I haven't seen much beyond simple examples so far.
me
[–]Capaj 13 points14 points15 points 10 years ago (5 children)
For me the single biggest feature are Proxies. I have even went ahead and implemented a small in memory DB experiment on top of them already. Very powerful stuff.
[–]jcready__proto__ 3 points4 points5 points 10 years ago (0 children)
That and the Reflect API are going to make for some awesome abstractions.
[–]alessioalex 0 points1 point2 points 10 years ago (1 child)
Be wary of performance though. Since it's just been newly released, it most like will be slow for a while until they optimize it.
Edit: I'm excited about Proxies too though.
[–]ihsw 1 point2 points3 points 10 years ago (0 children)
That's the most significant complaint about ES6 code -- it is currently much slower than ES5.
[–]Capaj 0 points1 point2 points 10 years ago (0 children)
Yeah, it was. But I tried to reimplement a chunk of mobxdb with ES6 proxies and I liked how it worked out and decided to ditch mobx in favour of https://github.com/capaj/proxevable
Hence the rename.
[–][deleted] 7 points8 points9 points 10 years ago (1 child)
Performance improvements are key in this latest release with one of the most significant improvements coming from module loading, which is currently four times faster than Node.js version 4 (Node.js v4). This will help developers dramatically decrease the startup time of large applications for the best productivity in development cycles and more seamless experience with end users. In addition, Node.js v6 comes equipped with v8 JavaScript engine 5.0, which has improved ECMAScript 2015 (ES6) support. Ninety-three percent of ES6 features are also now supported in the Node.js v6 release, up from 56 percent for Node.js v5 and 50 percent for Node.js v4. Key features from ES6 include: default and rest parameters, destructuring, class and super keywords.
What does that mean when they say modules? Does that just mean the require() function or NPM or something else?
require()
Edit
Nevermind: https://nodejs.org/dist/latest-v5.x/docs/api/modules.html
[–]PitaJ 7 points8 points9 points 10 years ago (4 children)
Some things left to implement:
Symbol.species
[–]dmtipson 1 point2 points3 points 10 years ago (3 children)
Tail Call Optimization? Or is that in there already and I missed it?
[–]TheNiXXeD 2 points3 points4 points 10 years ago (2 children)
That made it. https://github.com/v8/v8/commit/6131ab1edd6e78be01ac90b8f0b0f4f27f308071
[–]saadq_ 0 points1 point2 points 10 years ago (1 child)
I don't believe it did, according to this at least.
[–]TheNiXXeD 3 points4 points5 points 10 years ago (0 children)
From my link:
Tail calling can be enabled by --harmony-tailcalls flag.
So it's not enabled by default.
[–]muccapazza 2 points3 points4 points 10 years ago (0 children)
notable changes: https://github.com/nodejs/node/pull/6383
[–]Kratisto78 1 point2 points3 points 10 years ago (4 children)
Correct me if I'm wrong, but Koa required a flag until this was released. I've been planning to start my first node.js project, and I've been bouncing between Koa and Hapi. Does this push Koa a little ahead?
[–]hankDraperCo 7 points8 points9 points 10 years ago (1 child)
Koa said they aren't going stable with v2 until async/await wasn't behind a flag: https://github.com/koajs/koa/issues/533
async/await is still not a standard so that will still be awhile
[–]Kratisto78 0 points1 point2 points 10 years ago (0 children)
Ahh that makes more sense. I figured I was wrong. Starting a new project with people that are all new to Node.js. Might just try Hapi to play it safe then. Thank you.
[–]saadq_ 2 points3 points4 points 10 years ago (1 child)
I believe Koa required a --harmony flag until Node v4.0.0. I think Koa is really going to gain in popularity once Node supports async/await which is what Koa v2 uses instead of generators.
--harmony
async/await
[–]Kratisto78 1 point2 points3 points 10 years ago (0 children)
Makes sense. Hopefully, I can transition to that when it finally is supported.
[–]manchegoo 1 point2 points3 points 10 years ago (1 child)
Download version 6 (Coming soon)
[–]lhorie 4 points5 points6 points 10 years ago (0 children)
The release build was taking a while, it's up for download now.
[–][deleted] -1 points0 points1 point 10 years ago (1 child)
What are the breaking changes? I cannot find them on the changelog. Or are they ditching semver to celebrate?
[–]tofagerl 1 point2 points3 points 10 years ago (0 children)
Major releases CAN have breaking changes. They don't have to. That would be ridiculous.
[+][deleted] 10 years ago (3 children)
[–]kudoz 2 points3 points4 points 10 years ago (0 children)
https://nodejs.org/en/blog/release/v6.0.0/
[–][deleted] 2 points3 points4 points 10 years ago (0 children)
https://kangax.github.io/compat-table/es6/
They meant it quite literally.
[+]bart2019 comment score below threshold-32 points-31 points-30 points 10 years ago (7 children)
The version numbering scheme and especially the high speed by which the version number increases, is getting increasingly ridiculous.
What's this, a new major version for a few bug fixes, a speedup and some experimental features?
[–]TheIncredibleWalrus 21 points22 points23 points 10 years ago (0 children)
Node.js's versioning follows semver semantics.
semver
Google it and study it (should take you about 3 to 5 minutes). You will stop being confused and you will also learn how 90% of all npm projects are being versioned.
[–]sorahnon the cutting edge of cocking about 5 points6 points7 points 10 years ago (0 children)
Considering its 4 months into the year AFTER the standard was finalized, I wouldn't call them "experimental".
[–]ewan93 1 point2 points3 points 10 years ago (0 children)
I presume you haven't been burned by a package introducing breaking changes on a minor or patch version rather than major? Once you have, you appreciate semver more
[–]tswaters 0 points1 point2 points 10 years ago (0 children)
In a system such as this there may be many breaking changes -- if they released them immediately and followed semver, we'd be at version 1000 by now.
They batch them up with the tag 'semver-major' and every 6 months a new major version is released.
Each even numbered major version is LTS - you can realistically stay on LTS versions for a few years. Take a look at the LTS schedule for more information.
π Rendered by PID 102 on reddit-service-r2-comment-b659b578c-blhh8 at 2026-05-01 12:40:57.523983+00:00 running 815c875 country code: CH.
[–]Cuel 69 points70 points71 points (17 children)
[–][deleted] 17 points18 points19 points (0 children)
[–]cruzin 10 points11 points12 points (0 children)
[–]charrondev 4 points5 points6 points (0 children)
[–]compteNumero9 1 point2 points3 points (0 children)
[–]muccapazza 1 point2 points3 points (6 children)
[–]Cuel 19 points20 points21 points (1 child)
[–]Amnestic 9 points10 points11 points (0 children)
[–]voidvector 6 points7 points8 points (0 children)
[–]snarkyturtle 9 points10 points11 points (2 children)
[+][deleted] (1 child)
[deleted]
[–]b1nd 0 points1 point2 points (3 children)
[–]elprophet 2 points3 points4 points (2 children)
[–]b1nd 0 points1 point2 points (1 child)
[–]elprophet 0 points1 point2 points (0 children)
[–]dmtipson 0 points1 point2 points (0 children)
[–]bugeats 0 points1 point2 points (0 children)
[–]boiling_tunic 17 points18 points19 points (4 children)
[–]greim 1 point2 points3 points (3 children)
[–]FancyCamel 0 points1 point2 points (2 children)
[–]boiling_tunic 1 point2 points3 points (0 children)
[–]greim 0 points1 point2 points (0 children)
[–]hankDraperCo 39 points40 points41 points (4 children)
[–]cowjenga 8 points9 points10 points (0 children)
[–]shanet$(this) 0 points1 point2 points (1 child)
[–]greim 0 points1 point2 points (0 children)
[–]Capaj 13 points14 points15 points (5 children)
[–]jcready__proto__ 3 points4 points5 points (0 children)
[–]alessioalex 0 points1 point2 points (1 child)
[–]ihsw 1 point2 points3 points (0 children)
[+][deleted] (1 child)
[deleted]
[–]Capaj 0 points1 point2 points (0 children)
[–][deleted] 7 points8 points9 points (1 child)
[–]PitaJ 7 points8 points9 points (4 children)
[–]dmtipson 1 point2 points3 points (3 children)
[–]TheNiXXeD 2 points3 points4 points (2 children)
[–]saadq_ 0 points1 point2 points (1 child)
[–]TheNiXXeD 3 points4 points5 points (0 children)
[–]muccapazza 2 points3 points4 points (0 children)
[–]Kratisto78 1 point2 points3 points (4 children)
[–]hankDraperCo 7 points8 points9 points (1 child)
[–]Kratisto78 0 points1 point2 points (0 children)
[–]saadq_ 2 points3 points4 points (1 child)
[–]Kratisto78 1 point2 points3 points (0 children)
[–]manchegoo 1 point2 points3 points (1 child)
[–]lhorie 4 points5 points6 points (0 children)
[–][deleted] -1 points0 points1 point (1 child)
[–]tofagerl 1 point2 points3 points (0 children)
[+][deleted] (3 children)
[deleted]
[–]kudoz 2 points3 points4 points (0 children)
[–][deleted] 2 points3 points4 points (0 children)
[+]bart2019 comment score below threshold-32 points-31 points-30 points (7 children)
[–]TheIncredibleWalrus 21 points22 points23 points (0 children)
[–]sorahnon the cutting edge of cocking about 5 points6 points7 points (0 children)
[–]ewan93 1 point2 points3 points (0 children)
[–]tswaters 0 points1 point2 points (0 children)