Skip to content
Advertisement

Tag: es6-promise

What’s the order of execution when we have callback inside promise?

I am new to JavaScript and, am not able to understand why the output of the following code:- is:- and not:- additionally, console.log(“async executed”) is not getting lagged for 10 seconds, instead, it gets executed immediately after the two synchronous console.log Answer As commented by @trincot, setTimeout is a function that immediately returns and execution will continue below it like

Why are promise function in executing in wrong order?

When I am executing separately that program gives the right solution but when I run all four it got messup. Expected Output: Getting username… Username = srishti Validating username… Valid Username! Getting password… Password = upgrad Validating password… Valid Password! BOTH VALID**** When I pass the first two functions as a callback function, it will then print the result as

Function recursion advice

I am building an employee tracking app. I want my app to work so that after each one of the functions for the various list selections is complete, the app will re-prompt you with the options list again. There are a few methods I can think of to achieve this but I was hoping a more seasoned developer could recommend

Calculate Value from JS Promise

I have assigned a callback function to a variable. The function then returns a promise stating it is fulfilled and the value. I want to be able to return the value and use it to perform a mathematical calculation. Javascript code: In the console I get the below output. Answer Assuming this is the interface you’re using, this is an

Advertisement