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
-1
votes
1 answer

Babel setup on ES7

I have been upgrading my project to use ES7. I have changed some codes, made use of classes. But there is a problem. class Example { change = async (params) => { const job = await Some.job(); } } Everytime I wanted to debug it gives…
msharpp
  • 349
  • 1
  • 5
  • 20
-1
votes
4 answers

How do I access the nested properties of an array in Loopback?

here, res = Array of results retrieved res = [ Object, Object, Object... Object ] Each Object looks like this: Object{ "userId": "ab1ce", "groupId": "a1de2" } Now, the results has an array of objects like this, how do i access the userId…
-1
votes
1 answer

Load data using Callback. Is there a better solution using ES6 Promises?

I have a method that is called in several places in the project. I've done method. the first method call do Ajax get, cache data in class property and fire callback. Second call method only call callback with cached data. I would like to add the…
Piotr Białek
  • 2,329
  • 1
  • 12
  • 26
-2
votes
2 answers

What is the best way to partially copy a JS object?

I'm working on a NodeJS project (using @babel/preset-env) and need to figure something out: If I have two objects, one of them identical to the other but possibly minus some fields (depends on input object), how do I edit the "larger" one such that…
MisutoWolf
  • 946
  • 11
  • 32
-2
votes
3 answers

ES6: How to go through an array of object and change one of the items in there

I'm trying to divide one item in array of objects by 1000 and return a new version with calculated value 0: {name: "Mon, 28", from: 10236, to: -0, time: "2019-01-28T18:51:04+01:00"} 1: {name: "Tue, 29", from: 10209, to: -0, time:…
akano1
  • 35,616
  • 17
  • 46
  • 62
-2
votes
4 answers

Trying to write this in a more elegant way. Can I use a ternary in this function?

I was working on this practice problem, and solved it, but I want a more elegant way of writing this code: // Usually when you buy something, you're asked whether your credit card number, phone number or answer to your most secret question is still…
-2
votes
1 answer

How to remove all `iframe` tags that are only in the current webpage?

I have a webpage that has various iframe tags. I want to remove a certain iframe that has visible content on that webpage but I couldn't find a selector for it, so I thought deleting all iframes would help: var iframes =…
user3578082
-2
votes
1 answer

javascript object array conversion in es6/7

I am new in Javascript, I usually need to handle conversion between object and array, but how can I do it more elegant or clean in ES6/7 such as use Spread syntax or lodash..., rather than use for loop iteration.(since I don't like mutable stuff.)…
wk9876
  • 97
  • 1
  • 5
-2
votes
1 answer

ES6 opposite of includes logic

in order to remove objects from array i can find the objects i want to remove using the following piece of code: this.data = this.data.filter(item => this.multipleSelectedIds.includes(item.id)) but than what happens is i assign to the this.data…
yariv bar
  • 794
  • 12
  • 31
-2
votes
1 answer

Proper way to write external javascript libraries

I have created a class/library. and I used the new class syntax with a constructor and its methods, now what? what should I put in it for using that in a external JS file? I have something like this class LoadBalancer { constructor() {/*...*/} …
-2
votes
2 answers

Initialise an array with same value, x times

If I have: let a = [1,3,4,5]; how do I dynamically set b to have the same length as a with each entry containing "<", i.e. Expected result: b = ["<","<","<","<"];
Baz
  • 10,775
  • 30
  • 121
  • 236
-3
votes
2 answers

Function call returning undefined

I have written the following code in javascript : class Screen { Screen(_width, _height){ this.width=_width; this.height=_height; } diagonal() { return Math.sqrt(Math.pow(this.width, 2) + Math.pow(this.height, 2)); } …
nidhi
  • 33
  • 6
-3
votes
2 answers

Remove object, with a common property, from array

Is there a way to remove an object from an array if a single property in that object is found in another object in that array? const arr = [{ car: 'bmw', notimportant: 'bla bla', },{ car: 'audi', notimportant: 'bli bli', },{ car: 'bmw', …
-3
votes
2 answers

How to change indexes keys an array of object in JavaScript

I have an array of object , [{name:'abc'},{name:'def'},{name:'ghi'}]. When I loop map() on this array I am getting array like [0:{name:'abc'},1:{name:'def'},2:{name:'ghi'}]. I want to change index number to string values like…
-3
votes
2 answers

Can I support all ES5, ES6, ES7 features?

Are there any ways to config a Reactjs project to support all ES5, ES6, ES7 features? I mean that I can write all the ES5, ES6, ES7 syntaxes. I am using babel and webpack.
user3089480
  • 101
  • 1
  • 8
1 2 3
29
30