what settimeout given function returns

 

let y = setTimeout(()=>{ return '123'; } , 2000);
console.log(y);

it will return the timer id only, if page has 5 timers, if it is last -> it will show 5

after load it returns console only, after certain time its not write into console

what ever we wanna execute after 2 secpmds  it will in ist params

setTimeout(() => {
console.log("This message will be logged after 2 seconds");
}, 2000);
setTimeout(() => {
console.log(esmyGreeting());
}, 2000);


w3schools 

<!DOCTYPE html>

<html>

<body>


<h1>The Window Object</h1>

<h2>The setTimeout() and clearTimeout() Methods</h2>


<p>Click "Stop" to prevent myGreeting() to execute. (You have 5 seconds)</p>


<button onclick="myStopFunction()">Stop!</button>


<h2 id="demo"></h2>


<script>

const myTimeout = setTimeout(myGreeting, 5000);


function myGreeting() {

  document.getElementById("demo").innerHTML = "Happy Birthday!"

}


function myStopFunction() {

  clearTimeout(myTimeout);

}

</script>


</body>

</html>

it will show after 5 secons happybirthday


<html>


<p id="demo"></p>
<p id="demos"></p>
<p id="demose"></p>
<p id="demof"></p>
<script>
function one()
{
return "13";
}
console.log(one());
console.log('vamsi');
const myTimeouts = setTimeout(msyGreeting, 5000);

function msyGreeting() {
document.getElementById("demof").innerHTML = "msyGreeting!"
}

const myTimeout = setTimeout(() => {
document.getElementById("demo").innerHTML = "Happy Birthday!";
}, 5000);

const myTimeout2 = setTimeout(() => {
myGreeting();
}, 5000);

const myGreeting = () => {
document.getElementById("demos").innerHTML = "Happy sBirthday!";
};
const myTimeout23 = setTimeout(() => {
smyGreeting();
}, 5000);

const smyGreeting = () => {
return 123;
};
console.log(myTimeout23);

const myTimeout2e = setTimeout(() => {
document.getElementById("demose").innerHTML = esmyGreeting();
}, 5000);
const esmyGreeting = () => {
return 123;
};

setTimeout(() => {
console.log("This message will be logged after 2 seconds");
}, 2000);
setTimeout(() => {
console.log(esmyGreeting());
}, 2000);
</script>
</html>








No comments:

Post a Comment

Event listening in react

 How we can listen to som eevents some envents fire like click or automatically user enters into input button , that is event on word type i...