Is there a shorthand for the following -
if(tld == "com" || tld == "net" || tld == "co" || tld == "org" || tld == "info" || tld == "biz")
{
//do something;
}
you could use an array
if(["","com","net","co","org","info","biz"].indexOf(tld) > -1) {
// do something
}
or if you are using jquery :
$.inArray(tld, ["com","net","co","org","info","biz"])
REF - Performance of OR operation ( || ) vs inArray()
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With