how to use wait() in javascript code example
Example 1: how to wait in javascript
function pause(ms) {
return new Promise(resolve => setTimeout(resolve, ms));
}
pause(1000)
Example 2: wait javascript
wait(ms) {
return new Promise(resolve => setTimeout(resolve, ms));
}
Example 3: how to wait in javascript
function sleep(ms) {
return new Promise(resolve => setTimeout(resolve, ms));
}
Example 4: js wait
<button onclick="setTimeout(myFunction, 3000)">Try it</button>
<script>
function myFunction() {
alert('Hello');
}
</script>