---
title: "Asynchronous JavaScript function"  
description: "Asynchronous JavaScript function"  
author: "Anonymous User"  
published: 2021-07-19  
updated: 2021-07-19  
canonical: https://www.mindstick.com/forum/156513/asynchronous-javascript-function  
category: "javascript"  
tags: ["javascript"]  
reading_time: 1 minute  

---

# Asynchronous JavaScript function

What is a [simple](https://yourviews.mindstick.com/story/1469/5-simple-ways-to-stay-fit-amp-healthy) example of an [asynchronous JavaScript](https://www.mindstick.com/articles/337707/explaining-the-promise-in-javascript-and-different-status) [function](https://www.mindstick.com/articles/13001/multi-statement-table-valued-user-defined-function-in-sql-server)?

## Replies

### Reply by Ethan Karla

[JavaScript](https://www.mindstick.com/articles/874/how-to-create-watermark-text-for-textbox-by-using-javascript) itself is synchronous and single-threaded. You cannot write an [asynchronous](https://www.mindstick.com/blog/178/synchronous-and-asynchronous-command-execution-in-c-sharp-dot-net) function; plain JS has no timing API. There will be no side-effects from parallel threads.\
What you can do is use some APIs provided by your environment (Node.js, Webbrowser) that allow you to schedule asynchronous tasks - using timeouts, ajax, FileAPI, requestAnimationFrame, nextTick, WebWorkers, DOM events, whatever. An example using setTimeout (provided by the HTML Timing API):

```
<!DOCTYPE html>
<html lang='en' xmlns='http://www.w3.org/1999/xhtml'>
<head>
    <meta charset='utf-8' />
    <title>Asynchronous JavaScript </title>
    <script>
        window.setTimeout(function () {
            console.log('Hello World');
        }, 1000);
        document.write('Hello');
    </script>
</head>
<body align='center'>
    <h1>Asynchronous JavaScript</h1>
</body>
</html>
```

Hope this information has cleared your confusion.\

Happy Coding!


---

Original Source: https://www.mindstick.com/forum/156513/asynchronous-javascript-function

Copyright © MindStick Software Pvt. Ltd. This Markdown version is provided for developers, AI systems, and offline reading.
