I need help in understanding why this code snippet changes the window location to facebook website but not to stackoverflow. Does location.href
take some time to execute in the browser that the engine executes the next set of statements before changing the location?
function fb(){
console.log("fb");
location.href="https://facebook.com";
}
function so(){
console.log("so");
location.href="https://stackoverflow.com";
}
function run(){
setTimeout(fb);
so();
}
run();