Questions tagged [ecmascript-2017]

Use this tag for questions about features finalized in ECMAScript 2017. Do *not* use this tag if the code in question merely *uses* one of the features, *unless* the feature is cause of the problem.

Proposals finalized in 2017 include:

387 questions
0
votes
0 answers

Why function in if condition is not hoisted in JavaScript?

How can a variable declared in if condition is hoisted and not function? Example 1: var x = 1; if(a = 1) { x += typeof a; } x; // 1number a; // 1 When tried same with function in SpiderMonkey and V8 hoisting didn't happen. Why not? What…
NAVIN
  • 3,193
  • 4
  • 19
  • 32
0
votes
3 answers

Why my instanceof operator doesn't respond true?

I'm trying out instanceof operator. I tried out something like this. function f(){ return f; } new f() instanceof f; // false Why this came out to be false, when these are true function f(){ return f; } new f() instanceof Function; //…
NAVIN
  • 3,193
  • 4
  • 19
  • 32
0
votes
1 answer

Converting a for loop to forEach not working

I have an object with some propreties: const carOptions = { mazda: 25000, tesla: 85000, bmw: 100000 } I would like to convert a for loop … for (let i = 0; i < cars.length; i++) { if (cars[i].checked) { return carOptions[cars[i].id] …
Tzar
  • 5,132
  • 4
  • 23
  • 57
0
votes
2 answers

How to apply filters to an array of JSON in JavaScript?

I have this result from my controller and want to catch some items. Let´s see some code: ``` [ { "id": 17, "corretora_id": 1, "user_id": 2, "order": null, "nome": "Johnny English", "telefone": "(11)0070-0070", …
0
votes
1 answer

Understanding JavaScript super() invocations by following the ECMAScript specification

Code class Parent { constructor() {} } class Child extends Parent { constructor() { super(); } } Background As I was trying to understand exactly how super() invocations in class constructors work, I followed the following sequence of…
Magnus
  • 6,791
  • 8
  • 53
  • 84
0
votes
1 answer

CallExpression vs NewExpression in ECMAScript 2017

According to this SO post, a CallExpression always contains a call and thus cannot be part of the expression following the new operator. However, ECMAScript 2017 states: MemberExpression: PrimaryExpression MemberExpression [Expression] …
Magnus
  • 6,791
  • 8
  • 53
  • 84
0
votes
1 answer

Where in the ECMAScript specification can we find exactly when new Lexical Environments are created?

Where in the ECMAScript specification can we find text that describes exactly when a new Lexical Environment is created? I could not find it in "8.1 Lexical Environments", which just loosely states: Usually a Lexical Environment is associated…
Magnus
  • 6,791
  • 8
  • 53
  • 84
0
votes
1 answer

Dynamic import in different folder

I have some trouble to import dynamicaly a class. I use alias for this projet : config.resolve.alias = { App: path.resolve('./src/'), Reactive: path.resolve('./app/') } I want to import a list of class : const classes = { foo:…
0
votes
1 answer

ES7 promises and awaiting async function which loops forever in background

This might be a special case: I want to read from a queue (AWS SQS), which is done by making a call which waits a few secs for messages, and then resolves - and call again and again in a loop as long as you want to process that queue (it checks a…
Esben von Buchwald
  • 2,772
  • 1
  • 29
  • 37
0
votes
1 answer

Javascript Async / Await get tasks done and finally do something else

I need to have a bunch of functions complete some tasks and in a final function do something with the results. I was thinking of using async / await? async function dosomething() { // do stuff // await till finished then grab the result…
user9855223
0
votes
1 answer

JS return doesn't wait for await

I am trying to use the async await. My app starts like this axios.get(`${ROOT_URL}/ccidxann.php`) .catch(err => console.error('axios error get', err)) .then(async res => { const html = res.data const jobList = await getJobList(html) …
Hayk Safaryan
  • 1,996
  • 3
  • 29
  • 51
0
votes
2 answers

What is the difference in writing a module.exports function?

I see different ways coders writing a module.exports function. 1st: module.exports = function() { return (async () => { })() } 2nd: module.exports = async () => { } What is the difference in 1st way and 2nd way? And what is the need of…
0
votes
1 answer

About async/await in koa2

I use async/await in koa2 like following const Koa = require('koa'); const app = new Koa(); app.use(async (ctx, next) => { await next() console.log("1------>"+Date.now()) }); app.use(async (ctx, next) => { await next() …
yupang
  • 155
  • 1
  • 2
  • 16
0
votes
1 answer

Async/await call action from React component

I have a method lookupComplete in react component that call action checkIfAssign, I need wait to response and depend on this response trigger in this method another methods. But recieve Promise {} "result". How to wait until resolve this…
Palaniichuk Dmytro
  • 2,943
  • 12
  • 36
  • 66
0
votes
1 answer

How to use try/catch, promise catch and async function correctly?

This is how my upload function looks like at the moment. I'm using apollo mutation in that to upload a file. I do not understand how to use try/catch and catch of the promise (which client.mutate() is) correctly. Also I declared the upload function…
user3142695
  • 15,844
  • 47
  • 176
  • 332