SetTimeOut function in JavaScript.

If you are preparing for JavaScript interview then be ready for one question related to SetTimeOut function. SetTimeOut function is a asynchronous function which after after the given interval of time for example. const name = SetTimeOut(()=>{console.log('rahul')},20)

In this example we get output after 20 milliseconds //rahul

But question that interviewer ask

const name=SetTimeOut(()=>{console.log('rahul')},1))

Const abc= SetTimeOut(()=>{console.log("india")},0)

Answer : rahul then india

Explanation SetTimeOut function is asynchronous function it first put aside name then abc and both are ready to run but we put name first or declare first therefore first name will display afterthat abc.