notes - Copy_page-0001
notes - Copy_page-0001
1.async Keyword
Key Points:
• The async keyword ensuresthat the function returns a Promise, even if the function does
not explicitly return a Promise.
•Itallows for the use of the awa it keyword inside the function.
Example:
example () .then ( ( result ) => console .log ( resu lt ) ) ; II Outpu ts : "Hello , Wor ld !"
2.await Keyword
• Purpose: The await keyword is used inside async functions to pause execution until a
Promise is resolved or rejected.
• Behavior:When await is used, the function execution is paused, and JavaScript waits for
the Promise to settle before proceeding.