I am currently contemplating the safety and reliability of assigning a variable within an if statement across different browsers. If it proves to be safe, then I am inclined to proceed with its usage.
The scenario involves reading the query string and checking if the variable SN is either Twitter or Facebook. If it matches, the if statement is triggered and the variable can be used. If the querystring variable is missing or contains a different value, the process moves to the else statement.
if(socialNetwork = (window.location.search.indexOf("SN=Twitter") > 0) ? "Twitter" : ((window.location.search.indexOf("SN=Facebook") > 0) ? "Facebook" : null))
{
alert(socialNetwork);
}
else
{
alert("nope");
}