mirror of
https://github.com/alrayyes/wiki.git
synced 2024-12-01 15:26:23 +00:00
573 B
573 B
id | title |
---|---|
189b65a7-906f-41fd-91cd-57c4cc5764d2 | JavaScript Promises Finally |
Introduction
Like Exceptions, since
ES2018 JavaScript
Promises also support .finally()
.
Syntax
promise
.then((result) => {})
.catch((error) => {})
.finally(() => {});
Shorthand
promise.finally(() => {});
is equal to
promise.then(
(result) => {
return result;
},
(error) => {
throw error;
}
);