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.
I prefer do function declaration
doSomething() //still works
function doSomething() {}
over
var doSomething = function() = {}
doSomething()
because with the function declaration, I don't have to worry about the order, it just got hoisted at the…
I have the following node js script:
const rp = require('request-promise')
let result = ''
let asyncdone = false
async function m() {
return await rp.get('http://google.com')
}
m().then((html) => {
result = html
asyncdone =…
I am using the babel env preset which allows me to use es2017. I have tested the padStart function on this example:
'a'.padStart(2, '0') which yields 0a. Which is correct and means it's working.
However, when I use it on an object it does not work.…
I couldn't find why I get this error:
And here is my code:
create: async (data) => {
const insertedData = await dbProvider.query('INSERT INTO users SET ?', data);
console.log(this);
return await…
Recently, I've read that there is a await operator in Javascript for waiting for a Promise object returned by an async function.
My goal is to use just functions that are provided by the standard Javascript without the need of any external…
I cannot for the life of me figure out why async/await behaves the way it does.
Consider this example.
I want a function that does some db initialization, and returns me the database object when it is done.
var globalDb = null;
const…
A global object has its key/value (thing) is set in an async function setter(); using await. How to asynchronously read the value of thing in another async function getter();?
I'm getting undefined error because the getter(); is running before the…
I read about await stop the execution while the promise don't get resolve. I'm trying to do the following in my React-native app:
static async getFromStorage(key) {
const value = await AsyncStorage.getItem(key);
console.log(value);
return…
I have an array of objects. Each object has a "tag" property with an array list. The values in this list repeat from object to object. I would like to sum up "cost" and "revenue" based on the "tag" arrays. Not sure explanation makes sense but I have…
Recently started learning Javascript.
Given an assignment for my class, to click a button (a number 10 is written on the button), and there has to be "Result = 55". (here all numbers from 0 to 10 are added)
To change words by clicking buttons, wrote…