ecmascript-6 Questions

6

Solved

I am using the new template literals (template strings) syntax of JavaScript ES6 Docs Here and I am not quite sure how to escape the dollar sign that is used to break the string to add a parameter....
Illimani asked 26/6, 2016 at 22:13

47

Solved

I am using ReactJS. When I run the code below the browser says: Uncaught TypeError: Super expression must either be null or a function, not undefined Any hints at all as to what is wrong would be...
Barboza asked 8/5, 2015 at 5:29

7

I am working in NodeJS. I have a great deal of legacy code including several packages that are used in many places. This code is all CommonJS, Node require() module structures. Node now supports ES...
Dracaena asked 24/4, 2021 at 18:38

4

Solved

I recently read the following in Kyle Simpson's You Don't Know JS: ES6 "[ES6 modules export] actual bindings (almost like pointers) to the identifiers in your inner module definition." My confusi...
Gemoets asked 31/8, 2016 at 22:6

6

Solved

Object.freeze() seems like a transitional convenience method to move towards using const in ES6. Are there cases where both take their place in the code or is there a preferred way to work with i...
Yaron asked 14/10, 2015 at 11:25

4

Solved

Hi I am trying to add a module to my code. In ES5 I used var promise = require('bluebird'); So I tried import { promise } from 'bluebird' but it didn't work any idea why?
Arrack asked 15/9, 2016 at 17:2

3

Solved

I start by saying that I am not 100% sure this is the problem, I mean using await and async. This is the scenario: I run this when I first load the page, and works fine, I get the data: e...
Langsyne asked 1/3, 2019 at 19:7

3

Solved

My problem is that I need the user to confirm if he wants to continue to close or refresh the page. If he press No, it won't close nor refresh the page. Please take a look at my code so far: useEff...
Bergerac asked 26/8, 2021 at 4:39

5

Solved

This code generates an error: function *giveNumbers() { [1, 2, 3].forEach(function(item) { yield item; }) } This is probably because yield is inside a function that is not a generator. Is the...
Meuser asked 5/12, 2015 at 11:18

17

Solved

I have always found the range function missing from JavaScript as it is available in python and others? Is there any concise way to generate range of numbers in ES2015 ? EDIT: MY question is diffe...
Forefend asked 29/4, 2016 at 21:39

2

I'm wondering if there's a standardized file extension for ES6 yet. So far I've seen .es6 and .es6.js as two options, but I'm curious if one is generally better supported by third party packages an...
Staffard asked 16/7, 2015 at 17:41

5

Solved

Is there a feature in JavaScript 6 that allows to map over multiple arrays ? Something like a zipper : var myFn = function (a, b) { console.log(a, b);} var arr1 = ['a', 'b', 'c']; var arr2 = [...
Rick asked 4/10, 2015 at 18:58

6

Solved

I can use a Map and then set values: const a = new Map([["a", "b"], ["c", "d"]]) Now if I want to apply a function to all values in a functional way (without for ... of or .forEach), I thought I...
Monteria asked 24/4, 2019 at 8:56

13

How to access the target (which is myArray) of myProxy here? function createProxy() { const myArray = [Math.random(), Math.random()]; return new Proxy(myArray, {}); } const myProxy = createProxy...
Kayo asked 29/6, 2018 at 7:33

4

Solved

Let's say you're developing a polyfill and don't want to shim a class if it already exists in the browser. How can this be done in ES6? The following is not valid because exports is not a statement...
Independent asked 20/9, 2016 at 0:26

3

Solved

I am trying to pass a useState setter to a child component, but unsure how to type this. const Parent = () => { const [count, setCount] = useState(0); return( Child count={count} setCount={s...
Melee asked 20/2, 2019 at 10:12

2

Solved

How do I assign a namespace using ES6 modules? I'd like to do with for example jQuery does, where the namespace is $ but doing it the intended ES6 way. All my modules are structured in separate fil...
Vigilance asked 8/2, 2016 at 2:4

4

I have been trying to import an ESM module written in typescript in nodejs. But I am getting the following error: An import path cannot end with a '.ts' extension. Util.ts export class Util { co...
Hauge asked 4/9, 2020 at 14:9

3

Solved

I have a need to detect when an observable (observedEvents) has been subscribed to, and then subscribe to another observable (triggerEvent). I don't want to subscribe to triggerEvent manually, but ...
Inellineloquent asked 14/6, 2017 at 22:20

3

In my React select input, I want to iterate through my drivers array and for each driver generate the with the single driver as value. But when I console log the target value I have only a [object ...
Masorete asked 28/11, 2016 at 15:43

7

Solved

Say, I have an object: const user = {_id: 1234, firstName: 'John', lastName: 'Smith'} I want to create another object without the _id key: const newUser = {firstName: 'John', lastName: 'Smith'}...
Declaim asked 12/11, 2016 at 12:3

33

I'm trying to add a React map component to my project but run into an error. I'm using Fullstack React's blog post as a reference. I tracked down where the error gets thrown in google_map.js line 8...

7

Is there a way to delay the evaluation of an array of promises using Promise.all()? Does it make sense to manually add a delay function to the end of each promise before adding them to the array? ...
Gond asked 21/11, 2017 at 18:8

19

When I try to run a JS file by babel command it is showing: "babel-node is not recognized as an internal or external command, operable program or batch file". I had created 1.js file in this w...
Marimaria asked 2/2, 2017 at 11:29

10

Solved

I was working with create-react-app and came across this issue where I get an error: Home does not contain an export named Home. Here's how I set up my App.js file: import React, { Component } fr...
Pondicherry asked 25/5, 2017 at 5:12

© 2022 - 2024 — McMap. All rights reserved.