Last active
July 7, 2019 05:26
-
-
Save jordic/80b1f544a369403d844855806ebb4bde to your computer and use it in GitHub Desktop.
order of exec
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
const out = () => console.log("Hola 2") | |
const out2 = () => console.log("Hola 4") | |
console.log("Hola 1") | |
out() | |
console.log("Hola 3") | |
Promise.resolve().then(out2) | |
console.log("Hola 5") | |
/* | |
Outputs: | |
Hola 1 | |
Hola 2 | |
Hola 3 | |
Hola 5 | |
Hola 4 | |
*/ |
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
import asyncio | |
async def next_tick(): | |
print("hello 2") | |
async def delayed(num=4): | |
print(f"hello {num}") | |
async def main(): | |
print("Hello 1") | |
await next_tick() | |
print("Hello 3") | |
asyncio.create_task(delayed()) | |
print("Hello 5") | |
if __name__ == "__main__": | |
asyncio.run(main()) | |
"""Outputs | |
Hello 1 | |
hello 2 | |
Hello 3 | |
Hello 5 | |
hello 4 | |
""" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment