function fun(){
console.log("Hi");
window.location.href="http://www.google.com";
console.log("Hello, how are you");
alert("I am good");
fun1();
}
function fun1(){
console.log("Whats up??");
}
In the above lines of code the location.href
is getting called before
console.log("Hello, how are you")
, alert
and fun1()
.
When I call the fun()
it executes all the statements below location.href
and then it redirects to https://www.google.com
. Is the location.href
call asynchronous in nature, and if not then what is happening?
I thought the moment it redirects the user to other page, the lines of code below it would never execute.
Any help/explanation is appreciated!
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…