GeezerVisonThe World Wide Web, restored to 800 pixels of glory. |
| Home|About|Gaming cabinet|Archives|How it works|Starter sites |
GeezerVison is showing www.geeksforgeeks.org — JavaScript async function expression - GeeksforGeeks JavaScript async function expressionLast Updated : 19 Jun, 2024 An async function expression is used to define an async function inside an expression in JavaScript. The async function is declared using the async keyword or the arrow syntax. Syntax:async function function_name (param1, param2, ..., paramN) { Parameters:
Return Value:It returns a promise to return the value or else throws an exception, whenever an error occurs. Example 1: In this example "GeeksforGeeks" is printed first and after an interval of 1000 ms, "GFG" is printed.
Output: GeeksforGeeks Example 2: Here, a file is made gfg.txt and as soon as the file is read it prints "Read the file" in the console. Else it prints an "error" when either the location of the file is wrong or it is not unable to read the file due to any other reason.
Output:
Read the file
errorExample 3: This is an example of an async function working in parallel.
Output: GeeksforGeeks Supported Browsers:
Comment Explore |
| You are visitor 01402503 — GeezerVison does not store the pages you look up. Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required. |