I'm new to javascript and programming and I am trying to understand this piece of code to implement in my project
function url_redirect(url){
var X = setTimeout(function(){
window.location.replace(url);
return true;
},300);
if( window.location = url ){
clearTimeout(X);
return true;
} else {
if( window.location.href = url ){
clearTimeout(X);
return true;
}else{
clearTimeout(X);
window.location.replace(url);
return true;
}
}
return false;
};
Source - https://stackoverflow.com/a/53706698. I can't figure out the logic in this. Why is a single '=' used in a if statement? What does if(window.location = url) mean?