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:

484 questions
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
  • 611
  • 1
  • 9
  • 28
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
  • 1,144
  • 2
  • 10
  • 18
19
votes
1 answer

Are the new async and await keywords in ES7 copied from C#?

Noticing that async and await aren't found in Java, where these new keywords in ES7 copied from the C# language? I'm curious as to the origin: Who proposed the keyword names and is someone in the JS community is leveraging concepts from the .NET…
sean2078
  • 5,131
  • 6
  • 32
  • 32
17
votes
2 answers

How to support ES7 in ESLint

I have a project setup with WebPack to use ESLint and I'm wanting to use ES7 for the inline bind operator ::. Currently I'm getting the parse errors shown…
Ryan Vice
  • 2,133
  • 3
  • 23
  • 33
16
votes
8 answers

TypeScript Type-safe Omit Function

I want to replicate lodash's _.omit function in plain typescript. omit should return an object with certain properties removed specified via parameters after the object parameter which comes first. Here is my best attempt: function omit
Salami
  • 2,849
  • 4
  • 24
  • 33
16
votes
2 answers

TypeScript: class composition

Based on this awesome Composition over Inheritance video by MPJ, I've been trying to formulate composition in TypeScript. I want to compose classes, not objects or factory functions. Here is my effort so far (with a little help from lodash): class…
Glenn Mohammad
  • 3,871
  • 4
  • 36
  • 45
15
votes
3 answers

React passing parameter with arrow function in child component

I have these parent and child component, I want to pass click function to select an item in child component. Yet it seems the function in child component become automatically called instead of waiting until the user click the element. To make it…
Dion Dirza
  • 2,575
  • 2
  • 17
  • 21
15
votes
1 answer

How jasmine clock works?

I don't want to read code for hours to find the relevant part, but I am curious how jasmine implements its clock. The interesting thing with it is that it can test async code with sync testing code. AFAIK, with the current node.js, which supports…
inf3rno
  • 24,976
  • 11
  • 115
  • 197
14
votes
3 answers

Ability to abort asynchronous call

I'm using babeljs with es7 style async/await methods. I have a main script that will call a async method on an array of objects that all return promises. I use Promise.all() to wait for all of those to return, however, these tasks could take a…
Greg A.
  • 199
  • 1
  • 1
  • 7
13
votes
2 answers

Circular dependencies in ES6/7

I was surprised to find that in Babel, I could have two modules import each other without any issues. I have found a few places that refer to this as a known and expected behaviour in Babel. I know that this is widely considered an anti-pattern by a…
Andrew
  • 14,204
  • 15
  • 60
  • 104
13
votes
1 answer

babel ES7 Async - regeneratorRuntime is not defined

I'm using browserify + gulp + babel in my project, and having problem with ES7 features. These are what I installed: babel-plugin-transform-async-to-generator@6.8.0 babel-plugin-transform-decorators-legacy@1.3.4 // for use…
modernator
  • 4,341
  • 12
  • 47
  • 76
12
votes
2 answers

Does ES6 support the Elvis operator?

Does Javascript / ES6 support the Elvis operator? Example: var x = (y==true) ?: 10; Example 2: var debug = true; debug ?: console.log("Value of x:" + x);
1.21 gigawatts
  • 16,517
  • 32
  • 123
  • 231
12
votes
2 answers

Is it a good practice to create base components and then extend them in React?

I'm just learning React and I am writing components using ES7 syntax. My idea is to create a base component which will contain some methods that I want all derived components to have. For example, I want to implement valueLink without the mixin, for…
tuks
  • 800
  • 3
  • 11
  • 27
12
votes
1 answer

Check if document exists in mongodb using es7 async/await

I'm trying to check if the user with the email provided exists in the collection users, but my function keeps returning undefined for every call. I use es6 and async/await in order to get rid of lots of callbacks. Here's my function (it is inside of…
Denis Yakovenko
  • 3,241
  • 6
  • 48
  • 82
11
votes
1 answer

TypeError: Cannot mix BigInt and other types, use explicit conversions

I am trying to generate a 20 digit random number: let code = Math.floor(10000000000000000000n + Math.random() * 90000000000000000000n) I have tried putting the numbers in BigInt() as well as adding a n after but still this error comes. Uncaught…
Manan Sharma
  • 507
  • 1
  • 5
  • 18
1 2
3
32 33