1// server.js
2
3function square(x) {
4 return new Promise(resolve => {
5 setTimeout(() => {
6 resolve(Math.pow(x, 2));
7 }, 2000);
8 });
9}
10
11async function layer(x)
12{
13 const value = await square(x);
14 console.log(value);
15}
16
17layer(10);
18
1// Normal Function
2function add(a,b){
3 return a + b;
4}
5// Async Function
6async function add(a,b){
7 return a + b;
8}
9