Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Awaiting inside JavaScript template strings
// save this as .mjs or as "node --input-type=module < file.js"
const delay = (ms, result) => new Promise(r => setTimeout(r, ms, result));
const interpolated = `Hello, ${await delay(1000, "World!")} Is this sync or async?`;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment