Questions tagged [ecmascript-next]

For questions about upcoming ECMAScript features that are not scheduled to be part of a specific version yet (anything that is a stage 3 or lower proposal).

Proposals for new ECMAScript features follow a specific process, where they go through the following stages:

  • Stage 0 (Strawman)
  • Stage 1 (Proposal): The committee expects to devote time to examining the problem space, solutions and cross-cutting concerns
  • Stage 2 (Draft): The committee expects the feature to be developed and eventually included in the standard
  • Stage 3 (Candidate): The solution is complete and no further work is possible without implementation experience, significant usage and external feedback.
  • Stage 4 (Finished): The addition will be included in the soonest practical standard revision

Proposals in stage 4 are definitely added to one of the next releases of the language specification. This tag is for questions about proposals in stage 0 - stage 3.

Important Links:

379 questions
188
votes
4 answers

How to use arrow functions (public class fields) as class methods?

I'm new to using ES6 classes with React, previously I've been binding my methods to the current object (show in first example), but does ES6 allow me to permanently bind a class function to a class instance with arrows? (Useful when passing as a…
Ben
  • 4,595
  • 7
  • 30
  • 42
161
votes
11 answers

One-liner to take some properties from object in ES 6

How one can write a function, which takes only few attributes in most-compact way in ES6? I've came up with solution using destructuring + simplified object literal, but I don't like that list of fields is repeated in the code. Is there an even…
137
votes
1 answer

JavaScript double colon (bind operator)

As you know, there is a proposal for a shortcut for .bind() function, so you can write: ::this.handleStuff and it will work like that in es5: this.handleStuff.bind(this) My question is: will it be possible to pass arguments this way? I mean a way…
Victor Marchuk
  • 10,195
  • 10
  • 36
  • 62
132
votes
5 answers

async/await implicitly returns promise?

I read that async functions marked by the async keyword implicitly return a promise: async function getVal(){ return await doSomethingAync(); } var ret = getVal(); console.log(ret); but that is not coherent...assuming doSomethingAsync() returns a…
Alexander Mills
  • 1
  • 80
  • 344
  • 642
88
votes
8 answers

How to know if a function is async?

I have to pass a function to another function, and execute it as a callback. The problem is that sometimes this function is async, like: async function() { // Some async actions } So I want to execute await callback() or callback() depending on…
Facundo Matteo
  • 1,687
  • 1
  • 12
  • 19
86
votes
3 answers

What is ESNext?

I've come across the term ESNext, and wondering it is the same as the ECMAScript. So, I have these questions here: What is ESNext, actually? Does it refer to any specific version of ECMAScript?
Aaditya Sharma
  • 2,125
  • 1
  • 19
  • 34
85
votes
7 answers

JavaScript array .reduce with async/await

Seem to be having some issues incorporating async/await with .reduce(), like so: const data = await bodies.reduce(async(accum, current, index) => { const methodName = methods[index] const method = this[methodName] if (methodName == 'foo') { …
benhowdle89
  • 34,076
  • 63
  • 192
  • 314
85
votes
6 answers

Difference between async/await and ES6 yield with generators

I was just reading this fantastic article «Generators» and it clearly highlights this function, which is a helper function for handling generator functions: function async(makeGenerator){ return function () { var generator =…
78
votes
12 answers

Error: Missing class properties transform

Error: Missing class properties transform Test.js: export class Test extends Component { constructor (props) { super(props) } static contextTypes = { router: React.PropTypes.object.isRequired } .babelrc: { "presets": ["es2015",…
speak
  • 4,132
  • 3
  • 33
  • 41
64
votes
3 answers

What does the at symbol (@) do in ES6 javascript? (ECMAScript 2015)

I'm looking at some ES6 code and I don't understand what the @ symbol does when it is placed in front of a variable. The closest thing I could find has something to do with private fields? Code I was looking at from the redux library: import React,…
Kevin Wu
  • 8,193
  • 5
  • 24
  • 28
62
votes
3 answers

Succinct/concise syntax for 'optional' object keys in ES6/ES7?

There are already a lot of cool features in ES6/ES7 for defining Javascript objects. However, the following pattern is common in Javascript: const obj = { requiredKey1: ..., requiredKey2: ... }; if (someCondition) { obj.optionalKey1 =…
Andrew Mao
  • 31,800
  • 17
  • 126
  • 212
59
votes
4 answers

Why await is not working for node request module?

I'm new to nodejs. I’m not seeing the response in ex 1, but i see in ex 2. Why? Await works for me in other places, using babel. Ex 1 let res = await request(url) console.log(res); console.log(res.body); Ex 2 request(url, function (error, res,…
user43286
  • 2,001
  • 2
  • 23
  • 38
57
votes
3 answers

Is it better to define state in constructor or using property initializers?

According to this babel documentation, the correct way to use ES6+ with React is to initial components like this: class Video extends React.Component { static defaultProps = { autoPlay: false, maxLoops: 10, } static propTypes = { …
abustamam
  • 1,317
  • 2
  • 12
  • 21
57
votes
5 answers

Transpile Async Await proposal with Babel.js?

There is a proposal for introducing C# style async-await. I know Babel.js transpiles ES6 to ES5, but is there any way to make it transpile async-await to ES5?
tldr
  • 10,743
  • 11
  • 69
  • 111
56
votes
2 answers

Events vs Streams vs Observables vs Async Iterators

Currently, the only stable way to process a series of async results in JavaScript is using the event system. However, three alternatives are being developed: Streams: https://streams.spec.whatwg.org Observables:…
Daniel Herr
  • 14,666
  • 4
  • 39
  • 56
1
2 3
25 26