Questions tagged [ecmascript-2016]

Questions about new features specified in the ECMAScript 2016 specification.

This tag targets ECMAScript 2016, a JavaScript standard previously known as ECMAScript 7. Any proposal that reached stage 4 by Jan 28th, 2016 became part of the new version.

These are:

440 questions
32
votes
3 answers

Difference between ECMAScript 2016 exponentiation operator and Math.pow()

What is the benefit to using the ECMAScript 2016 exponentiation operator over the current Math.pow()? In other words, besides reducing key strokes, what is the difference between Math.pow(2, 2) => 4 and 2 ** 2 => 4
Matt
  • 3,680
  • 5
  • 21
  • 33
30
votes
2 answers

Can I catch an error from async without using await?

Can errors from a non-awaited async call be caught, sent to an original encapsulating try/catch, or raise an uncaught exception? Here's an example of what I mean: async function fn1() { console.log('executing fn1'); } async function fn2() { …
dvlsg
  • 4,568
  • 1
  • 25
  • 34
30
votes
5 answers

Is there support for static typing in ECMAScript 6 or 7?

Is there any support for static typing in ECMAScript 6? How about ECMAScript 7?
Mojtaba
  • 1,080
  • 1
  • 10
  • 28
28
votes
3 answers

ES7 Getting result from an array of promises using await generator

Given an array of promises, what's the idiomatic way to get the results in ES7? Here's what I want to do: async function getImports() { let imports = [System.import('./package1.js'), System.import('./package2.js')]; let promises = await*…
Matt K
  • 4,314
  • 3
  • 19
  • 33
28
votes
1 answer

Can anyone explain what es7 reflect-metadata is all about?

Been studying ES6, JSPM & angular2 for a week now and I found this repo ES6-loader if we look at the index.html at the bottom script you'll see System.import('reflect-metadata') .then(function() { return System.import('app/index'); }) …
Armeen Harwood
  • 15,195
  • 30
  • 106
  • 210
26
votes
4 answers

javascript : Async/await in .replace

I am using the async/await function the following way async function(){ let output = await string.replace(regex, async (match)=>{ let data = await someFunction(match) console.log(data); //gives correct data return data }) return…
ritz078
  • 1,895
  • 2
  • 19
  • 22
25
votes
7 answers

Destructure array to object property keys

I have an array of values like: const arr = [1,2,3]; Is there any way I can use destructuring to create the following output? If not, what is the easiest way I can do this in ES6 (or later)? const obj = { one: 1, two: 2, three: 3 }; I…
CodingIntrigue
  • 65,670
  • 26
  • 159
  • 166
24
votes
6 answers

Find all matching elements with in an array of objects

I have an array of objects I am searching within the array like this let arr = [ { name:"string 1", arrayWithvalue:"1,2", other: "that" }, { name:"string 2", arrayWithvalue:"2", other: "that" }, { name:"string 2",…
ankur
  • 3,890
  • 13
  • 52
  • 91
24
votes
3 answers

How can I use ES7 in nodejs?

How can I use ES7 (ECMAScript 2016) in nodejs? How can I use it in production? And in which version of node, I don't need using any module for doing that? Any help is appreciated.
Majid Parvin
  • 3,099
  • 5
  • 19
  • 37
24
votes
5 answers

ES6 / ES7 support in Visual Studio 2015 Community

I'm hearing that VS 2015 is supporting the new js syntax but when I open up a project written using aurelia.js in this IDE intellisense complains about many, many things eg. export class UpperValueConverter { toView(value){ return value &&…
Marek M.
  • 3,737
  • 7
  • 36
  • 76
23
votes
2 answers

Browser support for array.includes and alternatives

I looked it up and found this regarding finding a substring in a larger string in an array. Array.Prototype.includes if (t.title.includes(searchString)) My t is part of a $.each that's iterating through a larger array of objects (each objects got a…
Thaenor
  • 601
  • 1
  • 8
  • 26
20
votes
4 answers

(_.merge in ES6/ES7)Object.assign without overriding undefined values

There is _.merge functionality in lodash. I want to achieve the same thing in ES6 or ES7. Having this snippet: Object.assign({}, {key: 2}, {key: undefined}) I want to receive {key: 2}. Currently I receive {key: undefined} This is NOT a deep…
Filip Bartuzi
  • 5,027
  • 6
  • 42
  • 92
20
votes
1 answer

Redux - How to add entry to array in reducer

I stuck with this bit and I can't progress - I guess solution is simple but I can't figure out. I'm trying to add entry in reducer so data in in would look something this: state = { entryId: { entryName: ["something", "something2",…
eloleon
  • 904
  • 2
  • 8
  • 18
19
votes
3 answers

Can I fire and forget a promise in nodejs (ES7)?

I would like to run this code with babel: redisClientAsync.delAsync('key'); return await someOtherAsyncFunction(); inside an async function without await the first line. is this OK? how else can I run something that I don't care? Can I just fire…
arisalexis
  • 1,732
  • 2
  • 16
  • 38
18
votes
3 answers

Is the Fetch API an ECMAscript feature?

I've looked through the MDN resources here as well as here, as well as the WhatWg Fetch Spec, and for all that I can't figure out if the Fetch API is part of ECMAScript 5, 6, 7 or otherwise. All I can tell is that it isn't implemented consistently…
Ben
  • 3,987
  • 6
  • 30
  • 47
1
2
3
29 30