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.

0
votes
1answer
26 views

Difference between obj.key=value and obj.set(key, value)?

So while trying to update a document in mongoose, I realized that when I do obj.key=value to a document I obtained with Model.findOne(), it doesn'st assign the property to its value. But after trying ...
0
votes
0answers
11 views

How to add methods from a class to an existing object of another class

I had one big class that I split in two and load them separately on a page to improve performance. Core part is loaded first synchronously as it contains critical functionality while Extension (non-...
0
votes
0answers
8 views

Apollo server playground not working on heroku (Working Locally)

I am Trying to deploy run node js application on heroku, it is deployed successfully but playground doesn't seems to work. I came around this solution by setting introspection: true: https://github....
0
votes
1answer
17 views

Cannot override onSubmit handler of the form inside React component

my problem is simple but I cannot seem to figure it out and ashamed to even ask it here. I need to prevent full page refresh by my form. I know that I have to override its onSubmit(e) handler and call ...
0
votes
1answer
17 views

Exporting default from subdirectory

Suppose I have a file structure that looks like this –Directory --myComponent.js ––Subdirectory –––fileA.js –––fileB.js –––index.js ––index.js My Directory/Subdirectory/index.js looks like this: ...
0
votes
5answers
39 views

Destructuring Assignment with objects inside array

Is there a way to unpack values from an array of objects using destructuring assigments? [ {a : 1}, {a : 1}, {a : 1}, {a : 1} ] The result I need here is an array: [1,1,1,1]
1
vote
1answer
51 views

How to delete Javascript created class?

I have some code: let new_user = new User({ username: 'someone' }, isValid => { if (!isValid) { // I need to delete this user class } }) I tried to do new_user = null, but ...
-2
votes
1answer
19 views

I don't know what to change in this code for it to work

This code. It suppose to create canvas, grass and animals there. It doesn't even draw canvas. Please help. I will be very grateful. This two files (setup.js and classification.js) I have tied to my ...
0
votes
2answers
42 views

Is it possible to create an object from an array via destructuring? [duplicate]

Is it possible to do this: const foo = [1, 2]; const bar = { a: foo[0], b: foo[1], c: 'something else not in array' }; as a single statement, avoiding the need to declare foo? As ...
0
votes
2answers
30 views

How can I provide protection and confidentiality?

I want to restrict access to certain things in the JavaScript language from the outside. I've done some research on this, but I haven't been able to get anything I want. I know the underscore doesn't ...
0
votes
1answer
20 views

NodeJS: “Unexpected identifier” when trying to import module

I am trying to use ES6 imports in Node v10.15.3 LTS, but I keep running into the same syntax error. It occurs no matter whether I use esm, babel, or the --experimental-modules flag to enable support ...
5
votes
2answers
44 views

Why do I keep getting an array inside an array when using push()?

I am trying to understand MDN's documentation on .push() and .apply() because I'm having an issue where I am ending up with an array inside an array in a project. I have set up some experimental code ...
-3
votes
3answers
40 views

What is a JavaScript instance?

What is an instance in JavaScript? Can anyone provide an example please? Also, please explain your code.
1
vote
1answer
27 views

How to return a null value after destructuring?

I am trying to show and hide text based on a user's permission which is destructed from a user object which has the name, email and many more. I have tried setting a null value to the permissions ...
-7
votes
0answers
19 views

Ordenar em ordem alfabetica Typescript [on hold]

Gostaria de saber se exixste alguma funcao para deixa um campo ja existente de nome em ordem alfabetica, se sim qual e como usar mais o menos.
0
votes
1answer
44 views

Why my implementation of Promise.race isn't working?

I have a task, where I should implement function Promise.race without using it itsef. I've already found the code, which should work, but console throws an error "TypeError: promise is not a ...
1
vote
0answers
9 views

Constructor of class extending Float32Array called again after object creation

I am attempting to write a set of classes which extend Float32Array, but when it runs in Firefox, the constructor for the class gets called again when I try to use the object. This script ...
0
votes
2answers
24 views

How do i access the object after i defined its binding with braces?

I used the method described below to access a property of an object by the binding of the object but how do i access the object now? var {emri}={emri:"Arjon",mosha:23}; >emri <"Arjon" ...
-5
votes
1answer
41 views

Javascript Object to ES6 Classes

I have a javascript plugin written in vanilla javascript in Object Notation example start = { config: { a : 1 }, core: { engine_part1:function() { }, engine_part2: function() {...
2
votes
2answers
43 views

How to use ternary operator while pushing elements into the array

I am trying to add the objects into the array based on the condition. My expectation is to add two objects when the condition met but I am getting only the last object getting added (its element is ...
-2
votes
0answers
43 views

person.filter is not a function. I want to filter maritalStatus key from array [on hold]

I want to filter array having false maritalStatus from person object. let person = { name: 'alex', age: 24, employees: [{ age: 23, name: "bilal", maritalStatus: ...
1
vote
1answer
62 views

How to override css modules in react js

I have 2 themes for my site. When I import a topic for the first time, it is imported, the second time it does not change. I need to change the topic override css. How can I solve the problem? import ...
4
votes
3answers
45 views

A few things I don't understand about inheritance

I have created such a table on "inheritance". compare ---prototype---> Animal.prototype(constructor,run) Rabbit ---[[prototype]]---> compare Rabbit ---prototype---> Animal Rabbit.prototype ---[[...
0
votes
1answer
33 views

ES6 arrow function - find the most frequent item in an array [duplicate]

I need to create a very, very lean ES6 arrow function that consoles out the most frequent name in my array.... function mostFrequent(arr){ }; // Example usage let names = ['Jack', 'Anthony', '...
-1
votes
3answers
43 views

What is { xyz } = Object, where Object have xyz as property [duplicate]

What is { XYZ } = Object called ? where Object have xyz as property.
3
votes
8answers
72 views

Create array of objects by key from array of objects

There are a lot of questions like this on here, but I couldn't find one that matched my needs. I'm looking for a relatively simple solution on how to stack objects in an array into new arrays based on ...
0
votes
3answers
38 views

this not refer to the correct instance [duplicate]

I have these two classes class Foo { name ='Foo'; foo() { const bar = new Bar(this.onSomething); bar.bar(); } onSomething() { console.log(this)...
-4
votes
0answers
26 views

Save and send form data ing NodeJs [on hold]

I've tried different ways to send input form data with Text and URL parameters, but I can't find a way to store them and use them later on. Also tried storing the data in an array but it didn't work.
-1
votes
1answer
30 views

Why use const with Babel [duplicate]

Why use const when babel compiles everything to var? I get that the scoping would be a benefit and it is a bit more strict. But even then, why then differentiate between const and let when writing ...
0
votes
0answers
14 views

When switching DrawerNavigation in BottomTab, should change DrawerNavigation's header.title

Although I try all solutions on the internet but I couldn't solve that. I'm using three navigator types on my project and they are nested. Like this: Drawer > BottomTabNav > TopTabNav. I couldn't ...
-2
votes
0answers
6 views

Learn Node.js (and tools, frameworks, libraries)

What should Nodejs developer know (any another frameworks, libraries or tools) and how much time it will take.
0
votes
1answer
23 views

function variable dynamic setting

This question related to Syntactically anonymous/Arrow Function/add-hoc/factory DP functions: I have a component which is embedded in the Html. The component has a click event which is binded to a ...
0
votes
1answer
39 views

ES6: Retrieve response headers from a CORS fetch call

I have a react application using ES6 fetch API to call a rest endpoint using CORS. The fetch call work just fine, but I'm unable to get the response headers that are being sent from the server. I ...
0
votes
1answer
22 views

I have an import problem with D3 and typescript in intelliJ

Errors in browsers' console when I use d3.select() in typescript code. I've tried other methods like d3-timer.now() and had the same problem. I'm new to typescript. I'm using intelliJ Ultimate 2019....
-2
votes
0answers
43 views

Nested Array filter with objects and string [on hold]

const usersLanguageData = { transactionId: 6847655349501841000, count: 5, providerList: [ { code: ['US'], weekendOfficeHours: false }, { code: ['US', 'IND']...
0
votes
1answer
13 views

noUiSlider ES6 import

I report here what I have reported here too: https://github.com/leongersen/noUiSlider/issues/971. I've installed noUiSlider with ES6 imports (no webpack) as suggested in the official repo https://...
1
vote
3answers
55 views

How to use object destructuring spread operator to delete multiple object properties

I am using in my reducers Map/Associative array to store object via string ID. When I need new item into Map I am using this construction rows: { ...state.rows, [row.id]: row } When I need delete ...
0
votes
0answers
32 views

export default in JavaScript confusion [duplicate]

// aoo.js const c =950; function hello(){ console.log(c); } export default hello; // moo.js import q from './aoo'; console.log(q(...
0
votes
2answers
31 views

return different response without persistent data?

I want to mock a server endpoint where when user hit the api the n times, the response will return extra properties value. for example the endpoint return this at first [{id: 1, price:null}] then ...
0
votes
1answer
52 views

Recursively filter an array of objects according to an array of conditions

I have an array with objects that I want to filter according to an indefinite number of conditions passed as parameters. Here's how I filter the array a with a array of conditions in hide () const ...
0
votes
0answers
25 views

update the modified value in Ngrx store using spread

I can't figure out the correct way to update my table dynamic key property in reducers state. I have below table object with dynamic key values and I need to update only the modified key values in ...
-3
votes
3answers
72 views

Find if arrays repeat and then select them [on hold]

I have multiple arrays in a main/parent array like this: var arr = [ [1, 17], [1, 17], [1, 17], [2, 12], [5, 9], [2, 12], [6, 2], [2, 12], [2, 12] ]; I have the ...
1
vote
2answers
25 views

Filter data based on Object with filter values

I have in my app some filters. Whenever I click search, the data should be filtered based on the values of the search. I don't know if there's a better way to do what I'm trying to do in a cooler way ...
0
votes
1answer
29 views
0
votes
1answer
21 views

object destructing with paramaters on function

If I have the following ES6 method: function myClothes([first, second, third]) { return { first: first, second: second, third: third } } How do I print out "sneakers pants shirt" in ...
0
votes
0answers
12 views

ES6, call specific module only on a specific page

I'm migrating my js app from coffeescript to ES6. In coffeescript I have this class class Init constructor: -> page ="#{$('body').data('page')}" @execute_page_js(page) ...
0
votes
2answers
48 views

Object preparation in JS before sending to server?

I'm trying to prepare an object to POST to my server to store some information. This object requires me to do a few GET requests depending on how the user chooses to gather all the information needed ...
1
vote
1answer
41 views

How to overload a library class using es6 syntax

I have in my projet different objects that extends some other object caming from a library. The object of the library extends the Object class of the library. So we have the following architecture :...
-1
votes
1answer
35 views

Grow and shrink table height dynamically

I have a dialog box and its body is divided into three parts - Body Title - Table - Footer Within body I have two div's. Div1 for Body Title and, Div2 for Table and Footer. .div2 { height: 88%;...
0
votes
0answers
15 views

Incorrect Error stack logging when using babel-node to compile

I using babel-node to run my es6 nodejs app. Here is my package.json "start": "nodemon --exec babel-node -- ./bin/index.js", .babelrc config file { "presets": ["@babel/preset-env"] } But ...

http://mssss.yulina-kosm.ru