function greetUserPromise(name) {
return new Promise((resolve) => {
console.log(`Hi ${name}`);
resolve();
});
}
function greetUserCallback(name, callback) {
callback();
console.log(`${name}`);
}
function greetforCall() {
console.log("Hello");
}
async function greetUserAsync() {
try {
await greetUserPromise("Arun");
console.log("Hello Arun");
} catch (error) {
console.error("An error occurred:", error);
}
}
greetUserAsync();
greetUserCallback("Arun", greetforCall);
Preview:
downloadDownload PNG
downloadDownload JPEG
downloadDownload SVG
Tip: You can change the style, width & colours of the snippet with the inspect tool before clicking Download!
Click to optimize width for Twitter