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:

405 questions
215
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
  • 5,283
  • 9
  • 35
  • 44
191
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
  • 90,741
  • 139
  • 482
  • 817
177
votes
13 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…
166
votes
4 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
  • 3,330
  • 3
  • 24
  • 36
161
votes
11 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
  • 36,900
  • 69
  • 202
  • 331
149
votes
11 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
  • 2,347
  • 2
  • 16
  • 19
140
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
  • 13,045
  • 12
  • 43
  • 67
113
votes
3 answers

How to convert BigInt to Number in JavaScript?

I found myself in the situation where I wanted to convert a BigInt value to a Number value. Knowing that my value is a safe integer, how can I convert it?
Lucio Paiva
  • 19,015
  • 11
  • 82
  • 104
110
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
  • 35,740
  • 23
  • 143
  • 224
103
votes
8 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 =…
Alexander Mills
  • 90,741
  • 139
  • 482
  • 817
95
votes
14 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
  • 5,202
  • 4
  • 36
  • 41
81
votes
10 answers

Is there a way to short circuit async/await flow?

All four functions are called below in update return promises. async function update() { var urls = await getCdnUrls(); var metadata = await fetchMetaData(urls); var content = await fetchContent(metadata); await render(content); …
sbr
  • 4,735
  • 5
  • 43
  • 49
75
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,461
  • 5
  • 28
  • 28
68
votes
5 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,261
  • 3
  • 31
  • 42
65
votes
7 answers

While loops using Await Async.

This Javascript function seems to use the while loop in an asynchronous way. Is it the correct way to use while loops with asynchronous conditions? var Boo; var Foo = await getBar(i) while(Foo) { Boo = await getBar3(i) if (Boo) { …
1
2 3
26 27