This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//the variable myNewPromise is a function that takes | |
//2 arguments, isResolved and IsNotResolved | |
const myNewPromise = new Promise((isResolved, isNotResolved)=>{ | |
// we create a new variable isThePromiseResolved | |
//set it to true because we want it to be resolved.. right now | |
let isThePromiseResolved = true; | |
//what the if statment is saying is, | |
//if (isThePromiseResolved) is true (which it is) | |
if(isThePromiseResolved){ | |
//then we execute isResolved! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//first we define our new function as async and give it a name of f, with no arguments... or data between () | |
async function f() { | |
//we make some data that will run normally | |
let result = 'first!'; | |
//we make a new promise that takes 2 arguments, resolve, reject | |
let promise = new Promise((resolve, reject) => { | |
//we set a timeout so that out promise takes 1 second before it is finished | |
//when it is done, we resolve it with the messsage done! | |
setTimeout(() => resolve('done!'), 1000); | |
}); |