# What about async functions?

**URL:** <https://forum.code.org/t/what-about-async-functions/36507>\
**Category:** CS Discoveries\
**Tags:** gamelab\
**Created:** [May 23, 2022, 11:10pm UTC](https://forum.code.org/t/what-about-async-functions/36507 "2022-05-23T23:10:57Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![MonsterYT\_ALT](https://sea2.discourse-cdn.com/flex016/user_avatar/forum.code.org/monsteryt_alt/32/7536_2.png) [@MonsterYT\_ALT](https://forum.code.org/u/MonsterYT_ALT)\
**Post date:** [May 23, 2022, 11:10pm UTC](https://forum.code.org/t/what-about-async-functions/36507/1 "2022-05-23T23:10:57Z")

</div>

I use game lab. I have been using it for almost 2 years and I recently realized that there is a javascript feature that isnt in game lab (if that makes sense). Its async functions. Like, am I doing something wrong? Because when I type:  
async function helloworld() {  
console.log(“Hello World!”)  
}  
it says “‘async’ hasn’t been declared yet.” Game lab’s coding language is javascript so I wouldn’t see why async functions wont work. When i try to use async functions on Visual Studio Code, it works.  
If anyone knows how to use async functions in game lab, please help lol

---

<div class="post-metadata">

**Author:** ![mwood](https://sea2.discourse-cdn.com/flex016/user_avatar/forum.code.org/mwood/32/4941_2.png) [@mwood](https://forum.code.org/u/mwood)\
**Post date:** [May 24, 2022, 2:07pm UTC](https://forum.code.org/t/what-about-async-functions/36507/2 "2022-05-24T14:07:33Z")

</div>

@MonsterYT_ALT,

Game Lab was built on the ES5 version of Javascript. Async functions weren’t a part of Javascript until ES8, so that’s why they don’t work.

Good luck!

Mike

---

<div class="post-metadata">

**Author:** ![varrience](https://sea2.discourse-cdn.com/flex016/user_avatar/forum.code.org/varrience/32/8042_2.png) [@varrience](https://forum.code.org/u/varrience)\
**Post date:** [January 18, 2023, 5:32am UTC](https://forum.code.org/t/what-about-async-functions/36507/3 "2023-01-18T05:32:52Z")

</div>

Greetings @MonsterYT_ALT,

In regards to your question it’s the way @mwood described, However there is such a way to mimic some form of that functionality so long as you don’t mind callbacks which is what most of ES5 relies on for asynchronous execution,

let me give you a basic rundown on how it operates

```auto
function asyncEcho(txt, callback) {
setTimeout(function() {
console.log(txt); // executes back what you said a second ago
if(typeof callback === 'function') {
callback();
} // sanitizes the callback if nothing is used
}, 1e3) // 1e3, scientific notation for 1,000 ms or 1 second 
}
// Let's put this function to actual use
asyncEcho("Hello", function() {
console.log("World");
});

```

Do keep in mind that anything you want executed after the callback needs to exist within it as I have stated **(this is not a replacement for the keyword async nor does it mimic exact behavior befitting of ES6)** but this should in theory be close enough if you are looking for something that can fill in what asnyc does
