Created
June 2, 2021 07:49
-
-
Save noseratio/621b208ea72a8056654ce08b84fccac8 to your computer and use it in GitHub Desktop.
Awaiting inside JavaScript template strings
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// https://dev.to/noseratio/await-inside-javascript-template-strings-3kbj | |
// | |
// 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?`; | |
console.log(interpolated) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment