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
-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,569
  • 1
  • 17
  • 26
-2
votes
2 answers

How to replace value in javascript or ecmascript?

I need to replace All in s3data Emp_Id with the response data's values(expected output appended), ignore 0 and 1 in response they are not required. S3data is json data I can't use inbuilt function like Object.fromEntries because they are not working…
dash
  • 35
  • 5
-2
votes
1 answer

How do I do "Reverse destructuring"

We all know about destructuring objects in ES6+ const myObject = {name: 'John', age: 30, eyeColor: 'brown'} const {name, age, eyeColor} = myObject ... is there a "cleaner" way to do the following? const name = 'John' const age = 30 const eyeColor =…
-2
votes
2 answers

How to simplify object

I have an issue here where the code is quite heavy and quite hard to read imo. I've simplified the code as much as I can but I was wandering if there's a way to simplify this code even further? Or maybe if there is any better terminology i could use…
-2
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', …
Álvaro
  • 2,255
  • 1
  • 22
  • 48
-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
  • 1,133
  • 1
  • 18
  • 33
-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
  • 40,596
  • 19
  • 54
  • 67
-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
  • 137
  • 1
  • 6
-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
  • 12,713
  • 38
  • 145
  • 268
-3
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…
-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
  • 11
-4
votes
1 answer

How can I sum object values by array data using ES standard?

I have an array of objects. Each object has a "tag" property with an array list. The values in this list repeat from object to object. I would like to sum up "cost" and "revenue" based on the "tag" arrays. Not sure explanation makes sense but I have…
-4
votes
3 answers

How to pass down custom props on initial render

I think it might be silly question to ask but trust me I didn't find an answer . I am passing down data via props to children component but I am stuck and getting error . Normally, I am passing data on form submit ( I mean when user type something…
1 2 3
32
33