ecmascript-6 Questions

8

Solved

Is it possible to access an object's key inside the name portion of a .each? let accounts = [ { details: { company_name: "company_name", email, password: "asdf", }, find: [ "_id", "c...
Infinite asked 28/6, 2019 at 1:49

6

let x; try { x = ...; } catch (e) { return } // rest of the code that uses `x` const y = x + ...; x is assigned exactly once, yet I have to use let instead of const. The other way would be: ...
Tappet asked 12/5, 2018 at 9:41

3

I'm using ESLint to make my JavaScript code style consistent. My favorite indentation level is 4 and I want my declarations style to be this: function () { let a = 1, bbb = 2; const cc = 3, d...
Feuillant asked 28/4, 2017 at 21:52

5

Is there a way to retrieve a function's default argument value in JavaScript? function foo(x = 5) { // things I do not control } Is there a way to get the default value of x here? Optimally, so...
Kriemhild asked 4/10, 2015 at 14:35

4

Solved

Is there any way to use the ECMAScript6 class notation to declare either a static class variable or a default value for an instance variable? Without class what I have in mind would be written as ...
Monomolecular asked 3/2, 2015 at 20:56

3

Solved

This is a clean version of the my situation: const person1 = { name: "Person1 Name", hairColor: "Brown", backpack: { color: "Army-Green", content: [ "item1", "item2", "..." ] } } And ...
Anticlimax asked 22/11, 2019 at 13:32

4

Hi I am struggling to find out how to call a toast after a successful data mutation using server actions in Nextjs 13. The toast is a client component since it uses a hook/context. How would I go a...
Aerodynamics asked 2/6, 2023 at 22:57

12

Solved

I get this error: Failed to load module script: The server responded with a non-JavaScript MIME type of "". Strict MIME type checking is enforced for module scripts per HTML spec. The project ...
Sarasvati asked 21/11, 2017 at 0:44

9

Solved

I have a kebabize function which converts camelCase to kebab-case. I am sharing my code. Can it be more optimized? I know this problem can be solved using regex. But, I want to do it without using ...
Bludgeon asked 27/7, 2020 at 13:10

9

Solved

I'm still getting my head around react hooks but struggling to see what I'm doing wrong here. I have a component for resizing panels, onmousedown of an edge I update a value on state then have an e...
Neogaea asked 20/3, 2019 at 16:4

5

Solved

I'm trying to use ES6 modules in Chrome. From all the examples I've looked at the following seems to be the right way to do it, but when I run it in Chrome's developer tools I get this error messag...
Rochelle asked 25/10, 2018 at 16:16

8

Solved

Often you have to pass an object as parameter. Functions accessing those objects are pass by reference and can change original object. Which depending on situation can be unwanted outcome. So is th...
Shikoku asked 31/5, 2019 at 22:22

2

Solved

There are two new methods of Array in ES6, Array.of() and Array.from(). The difference usage of them are mentioned in this page. However, I am confused with the usage of Array.of in this line // ...
Proclitic asked 13/1, 2016 at 6:30

5

Solved

When using a for of loop, both of these are allowed and work: const numbers = [1,2,3]; // works for(let number of numbers) { console.log(number); } // also works for(const number of numbers) { co...
Pointless asked 21/10, 2019 at 9:9

4

Let's say I have the following array: ['product' , 'model', 'version'] And I would like to have an object such as: { product: { model: { version: { } } } } However, that array is dyna...
Rule asked 29/8, 2018 at 12:10

4

Solved

How do I add <a> tag correctly? I get this error for adding <Link></Link> Uncaught ReferenceError: Link is not defined The code: render() { return ( <div> <Link c...
Led asked 13/10, 2016 at 8:43

3

I'm attempting to write a currency formatting function using Intl.NumberFormat. It works correctly when I pass it things like USD, or EUR as the currency, but seems to break when I pass it more obs...
Colleen asked 12/5, 2016 at 18:51

3

Solved

Is there any way to do this using node, whether natively or with a plugin? What I'm trying to accomplish is to choose loseless or lossy image compression depending on the input type. Loseless on a...
Ruthenian asked 5/4, 2018 at 5:12

8

I have Single sign on in place but for testing I want to read the values from the url localhost:4200/?id=test&name=testing&[email protected] and pass them to an API in app component. ...
Sienese asked 7/1, 2020 at 3:47

7

Solved

I'd like to the following but with a single line, if possible: import Module from './Module/Module;' export Module; I tried the following but it doesn't seem to work: export Module from './Modul...
Becalm asked 27/2, 2016 at 4:42

7

Solved

I want to implement something like a task runner which will be pushed new tasks. Each of those tasks could be some async operation like waiting on user or making API calls or something else. The ta...
Affirm asked 13/4, 2018 at 23:24

4

Solved

As I understand a promise is something that can resolve() or reject() but I was suprised to find out that code in the promise continues to execute after a resolve or reject is called. I considered...
Naresh asked 6/3, 2015 at 9:55

4

I hear that dynamic exports/imports are not allowed in es6. This website Uses the example export default 5 * 7; as if it were a legal, static export. This seems reasonable since it clearly evalua...
Deterioration asked 27/1, 2016 at 10:52

12

Solved

I'm creating a unit converter, and I want to put all of the conversion functions into their own file. Using ES6 export, is there any way to export all of the functions in the file with their defaul...
Other asked 2/4, 2018 at 18:25

2

I want to unit test some ES6 classes that are stored as modules. However, when I try to run my tests, import triggers an error message: Cannot use import statement outside a module which means I ca...
Ummersen asked 24/5, 2020 at 12:17

© 2022 - 2024 — McMap. All rights reserved.