Promise finally in JavaScript
Level 394 keystrokes
finally() is called regardless of whether the promise is fulfilled or rejected.
JavaScript code
// Promise.resolve() creates a resolved promise with value "done"1Promise.resolve("done") // then() receives "done" and prints it2 .then(val => console.log(val)) // finally() runs regardless of success or failure, good for cleanup3 .finally(() => console.log("cleanup"));Output
done cleanup
Practice typing this code. Results are not recorded in the rankings.
Symbols in this code
The symbols you type in this JavaScript code and how often they appear.
(× 6)× 6.× 5"× 4=× 2>× 2;× 1