次の略記はありますか-
if(tld == "com" || tld == "net" || tld == "co" || tld == "org" || tld == "info" || tld == "biz")
{
//do something;
}
次の略記はありますか-
if(tld == "com" || tld == "net" || tld == "co" || tld == "org" || tld == "info" || tld == "biz")
{
//do something;
}
配列を使用できます
if(["","com","net","co","org","info","biz"].indexOf(tld) > -1) {
// do something
}
またはjqueryを使用している場合:
$.inArray(tld, ["com","net","co","org","info","biz"])
正規表現を使用します。
if ( /^(com|net|co|org|info|biz)$/i.test(tld) ) {
// do something
}
switchステートメントの使用について考えましたか?このようなもの:
switch(tld)
{
case 'com':
case 'net':
case 'co':
...
...
// do something for all of them
break;
default:
// if you want you can have default process here
break;
}
if (~["com", "net", "co", "org", "info", "biz"].indexOf(method)){/*Do somthing if true*/}
if (!~["com", "net", "co", "org", "info", "biz"].indexOf(method)){/*Do somthing if false*/}