Questions tagged [ecmascript-6]

The 2015 version of the ECMAScript specification, now a standard (ECMAScript 2015). Only use this tag where the question specifically relates to new features or technical changes provided in ECMAScript 2015.

Filter by
Sorted by
Tagged with
-4
votes
0answers
14 views

How to get month and index of array object days of last 6 months?

i have list object days, i want get item of list and index of last 6 months, starting from the last value of the array Example: "2019/08/22, 2019/07/22, ... ,2019/03/22 (last 6 months) and index of ...
3
votes
2answers
47 views

Typescript destructuring with required parameter

I'm trying to create a constuctor with some optional parameters and some required export class PageConfig { constructor({ isSliding = false, }: { isSliding?: boolean ...
0
votes
3answers
45 views

Replace part of string with variable with Regex(Regular expression) condition match javascript

I was thinking is possible to replace this condition match to a link in the map method. The end goal, I want to replace address apt #number to be a link after it render. But the address is wrap with ...
0
votes
0answers
14 views

react-big-calendar navigate to specific day

it might be silly question to ask but trust me I am new to react . Actually , current React-big-calendar support navigate to specific date which are selected from Month view . I want same thing when ...
0
votes
4answers
55 views

Scope of arrow function vs es5 function in setTimeout

I am experimenting with this and arrow functions. Ran into some trouble regarding the lexical scope of arrow function in setTimeout. The makeSound method returns this as the dog object. Why does it ...
0
votes
0answers
20 views

Asynchronous var closeAbbre is not defined

I am trying to load html and js through my templateloader.js file, using fetch and by creating script element and adding it to DOM. I got multiple files which shares variables and at last I bind these ...
2
votes
2answers
55 views

Sort array of objects by key values and displaying them on a HTML element

I'm making a movie sorter list, you enter the title and then the rating and it will show you the movies in order by rating. I have an array of objects and I managed to sort the array by rating, but I ...
1
vote
2answers
38 views

Sort mixed alpha/numeric Array in javascript

I have a mixed array that I need to sort by digit and then by alphabet var x = ['1','2A','2B','2AA','2','10A','10','11','12A','12B','12'] Desired Output sortedArray = ['1','2','2A','2B','2AA','10'...
0
votes
1answer
51 views

Get Object keys in insertion order in JavaScript

I have a large JavaScript object which has keys beginning with an integer like: const obj = { '0//America' : ['New York', 'Dallas', 'SF'] , '0//UK' : ['London'] , ...
1
vote
2answers
41 views

Unable to convert a nested object into an array of objects and viceversa

I am having an object of the following kind: var sourceObj = { "feature1": [ {"id":"1","name":"abc","enabled":false,"type":"type1"}, ...
1
vote
1answer
18 views

Deferred export in EcmaScript modules (JavaScript)

Is it possible to perform deferred export in EcmaScript modules (after executing some async operations in importing script, for example)? function do_export() { export default class AsyncClass { ...
0
votes
0answers
25 views

Babel is failing to compile ES6 to ES5

Babel Config { "presets": [ ["env", { "targets": { "browsers": [ "last 10 versions", "ie >= 8" ] } }] ] } Whenever I'm putting ES6 code ...
1
vote
2answers
49 views

Formatting of JavaScript Objects, Showing Sub Products under Products

I have an array of objects for products I want to show objects that have a parent ID under their parent object with property called subproduct I have a array object like let products = [{ "...
4
votes
8answers
112 views

Get count from Array of arrays

I have an array of arrays below. With ES6, how can I get a count of each value Good, Excellent & Wow into a new array e.g [{name: Good, count: 4} {name: Excellent, count: 5}, {name:Wow, count:2}] ...
0
votes
0answers
4 views

How Do I Transpile ES6 Written in AMD for Karma Tests

I have some modules ES6 modules configured as AMD modules (RequireJS) that I want test using PhantomJS with the Karma test runner (with Mocha). How could I set up my Karma pipeline to use Babel to ...
-7
votes
4answers
188 views

Split an array into 2 arrays grouped by object attributes [duplicate]

I can achieve splitting an object to arrays and grouped by attributes using classic for loops and conditions, but I would like to take advantage of JavaScript functional features such as map, filter ...
0
votes
1answer
11 views

Get URL for EcmaScript module after importing in browser

My start HTML: <!DOCTYPE html> <html lang="en"> <head> <script type="module" src="/way/to/app.js" defer></script> </head> <body>...</body> </...
1
vote
0answers
49 views

ES6 code completion (Intellisense) with composition in VSCode

I am trying to get code completion to work when nesting classes in es6 using the following syntax: class Dog extends FoodMixin(Animal). The first implementation works fine, giving me auto completion ...
0
votes
1answer
37 views

JavaScript Convert nested Map to object

I want to convert an es6 nested Map to an object. I tried this code: mapToObjectRec(m) { let lo = {} for(let[k,v] of m) { if(v instanceof Map) { lo[k] = this....
0
votes
4answers
47 views

are javascript const really constant? in redux?

I have this reducer in my store, where the initial state initialProcessingState is imported from another source file. import { ACTN_IS_PROCESSING } from '../config/action-types.js'; import { ...
0
votes
1answer
57 views

Why is this working: updating array element in state with spread operator

When reading React Cookbook I've stumbled upon a code snippet, this function gets called when user checks a task as completed in a TODO list: markAsCompleted = id => { // Finding the task by ...
0
votes
3answers
79 views

What are “class fields” in JavaScript?

I was reading about JavaScript classes, and came across this term "public class fields syntax". On digging a bit deeper into it I came across this Babel's documentation on class properties. Can ...
-1
votes
0answers
54 views

How to compare data using Fetch API?

I want to compare username and then want to print the data of the user of matched username I fetched the data using Javascript Fetch API but facing problem in comparing the username This is the ...
0
votes
0answers
16 views

on selection of one drop down other two drop down value should come automatic

Here I my code I am creating form through array that I am calling in state . Now there are 3 drop down option , I am trying to set state and country fields on selecting on lga . Like If I select the ...
-3
votes
2answers
38 views

How to add string at the end of array push

I am trying to push values to an array it working fine but when I try second values like "5" , it added with every single array element . I want to save add value at the end of entire array if (data[...
1
vote
3answers
50 views

create a object from existing object using javascript

I have nested object array in which I would like to create a object in a format -combine all from cn_from, combine all cn_to with the respective id to new object. I would like to know how to do ...
0
votes
1answer
14 views

import and use jellyjs plugin parcel

I'm using parcel and came across using Jelly.js and tried to import as instructed import $ from "jquery"; import 'jquery-scrollify'; import { Jelly } from 'jelly.js'; $(function(){ var options = ...
0
votes
4answers
30 views

Convert to Object and Adding property to object of array

I want to make filter by date with this object of array const mapDateRange = () => {for (let elem in catchData) { let x = {startDate:catchData[elem][0],finishDate:catchData[elem][1]}; ...
3
votes
7answers
64 views

Summarize the frequency of array of objects

Assume I have the following array of objects. data = [ { x: 1, y: 1 }, { x: 2, y: 2 }, { x: 3, y: 3 }, { x: 2, y: 2 }, { x: 1, y: 1 }, { x: 1, y: 2 }, { x: 1, y: 1 } ] what I need is ...
1
vote
5answers
43 views

How to delete an item from an object of ids

const comments = { '1': { id: '1', text: 'please add code examples' }, '2': { id: '2', text: 'examples would be great for this article' }, '3': { id: '3', text: 'hi there' }, }; const ...
4
votes
1answer
34 views

What's the straightforward, supported, stable way of using ES6 syntax and Javascript minification with Rails?

I'm trying to use ES6 syntax in my Javascript files, in a Rails project. I also need to minify the Javascript files (mine, and the ones included by libraries like rails-ujs) for performance reasons. ...
-1
votes
2answers
45 views

React - input range with default step as an array of values

While working on a React Component, I'm trying to set a specific range of values to determine the step on a type range input. I'm able to reproduce the desired behavior with vanilla HTML and JS i.e. ...
1
vote
1answer
13 views

Adding JS Function inside Template Literal

I am trying to add .split() function inside template literal. I would like to add city = city.split(',')[0] ... instead of city inside i18n and remove the city = city.split(',')[0] before messages. ...
0
votes
0answers
20 views

How to stop executing map function on array index 5 in javascript [duplicate]

I have array of 10 elements, I am mapping to extract array data . I want to stop array executing when compile reached to array index 5 . I know it possible with for loop but I need it in map function. ...
0
votes
2answers
45 views

Reactjs pass variable to function from another class

Request.js export default class Request extends React.Component { getForm(e) { let v = validator(document.getElementById('myinput')); // here is should call function from another class } render(){ ...
0
votes
1answer
15 views

How to save multiple check box value in react

I think it might be silly question to ask but trust me I am new to ReactJS, I want to make a logic for checkbox . Actually, I have multiple checkbox in my program I want to save multiple check box ...
1
vote
0answers
42 views

How to use url query strings in my React search filter app

I tried to look around, but I'm having trouble understanding/implementing what I need to do. I have my search filter app set up with a search box and search categories, I want to be able to type ...
-1
votes
0answers
23 views

React : How to store multiple check box value in array [on hold]

I am new to React , actually I want to store multiple checkbox value in one array , I tried but I failed . could some one please help me how to solve this problem Thanks
0
votes
2answers
42 views

How can I overcome the browser storage limitations and being able to store more than 500 Mb of files?

I have a PWA application where the user must take several photos while offline. Those are then sent to the server once the user is online again. How can I overcome the browser storage limitations ...
0
votes
3answers
42 views

detect react scrolled to bottom element. scrollTop

What to do to access the scroll handler's event? can't access to offsetTop, scrollTop etc class App extends React.Component { handleScroll = e => { console.log(e.target.scrollTop)...
0
votes
2answers
49 views

how to loop through values of a nested object in javascript in es6

I am trying to use a condition if all values of an object is not equal to empty or null. I am trying to retrieve the values in es6. How can I achieve this? This is the object let obj = ...
-3
votes
2answers
54 views

How true+false===1 evaluates to true [duplicate]

I am trying to compare true+false to 1 i.e true+false===1 In the past, I tried the following: true===1 //false false===0 //false true-true===0 //true I expect the output to be false but ...
1
vote
1answer
49 views

Spread Operator not working while importing from const variable

I am facing some weird problem while import a const value in react. Actually, I am exporting a const which is not related to react like export const menu = [{ "icon": "si-home", "...
0
votes
0answers
32 views

How to detect executable files in a ZIP file while uploading it via Jquery [on hold]

I'm trying to upload a bunch of files in a single zip file. while uploading via server, I want to detect whether there are any .exe files in it or not. I'm using JBOSS+JAVA. I tried Finding similar ...
0
votes
2answers
38 views

Flow typing issue on conditional object property

I'm having this flow issue string [1] is not an object with the following code: type User = { name: string, age: number, gender?: string, } const user: User = { name: 'xxx', age: 23, ...(...
0
votes
2answers
49 views

Push an object into the array using spread operator?

I have an array of object like this, let array1 = [{id:1,name:'One'}] whenever i do api call, the array of objects getting updated like this let array2 = [{id:1,name:'One'}, {id:2, name:'Two'}] ...
1
vote
1answer
30 views

What is CoverInitializedName[yield] in ECMA-2015 syntax grammer

I'm writting my own ES6 parser. But I don't understand what is CoverInitializedName in ObjectLiteral. This is ECMA-2015 ObjectLiteral spec link: https://www.ecma-international.org/ecma-262/6.0/#sec-...
0
votes
2answers
33 views

Javascript text input on input text change format to two decimal places

Hi I have the below code which sanitises text entered in input text. let formattedText = text .replace(/[^0-9.]/g, "") // remove chars except number, point. .replace(/(\..*)\./g, "$1")...
0
votes
1answer
23 views

lodash debounce & ES6 class - this. is not a function

I have lodash debounce connected to an input which works well, however i cant seem to call other methods. I tried binding the search in my constructor. Here is my code: class SearchBar { ...
0
votes
1answer
30 views

Rendering checkboxes based on one array, and checked elements based on the second array

Expected effect: Render 4 checkbox (from this.state.people): Paul Martin Joseph Gregor Based on this.state.peopleChecked checked Martin Gregor Code here: https://stackblitz.com/edit/react-...