setTimeout(() => {
console.log("Delayed for 1 second.");
}, "1000")
setTimeout(function(){
console.log("hello");
}, 3000); //wait for atleast 3 seconds before console logging
setTimeout(function(){
console.log("Executed after 1 second");
}, 1000);
import React, { useState, useEffect } from "react";
export default function App() {
const [count, setCount] = useState(0);
useEffect(() => {
const timeout = setTimeout(() => {
setCount(1);
}, 3000);
},[]);
return (
<div className="App">
<h1>{count}</h1>
<button onClick={() => setCount(count + 1)}>Increment</button>
</div>
);
}
function doHomeWork(subject, callback){
setTimeout(callback,500);
console.log("doing my homework:", subject)
}
doHomeWork("Maths", function(){console.log("finished my homework");});
<div class="toast" role="alert" aria-live="assertive" aria-atomic="true">
<div class="toast-header">
<img src="..." class="rounded me-2" alt="...">
<strong class="me-auto">Bootstrap</strong>
<small class="text-muted">11 mins ago</small>
<button type="button" class="btn-close" data-bs-dismiss="toast" aria-label="Close"></button>
</div>
<div class="toast-body">
Hello, world! This is a toast message.
</div>
</div>