1

If that the best code for that ?

if(window.location.origin.split(":")[1] > 4) {
    return false;
}else {
    return true;
}
Phrogz
  • 296,393
  • 112
  • 651
  • 745

1 Answers1

1

You want location.port (part of the location object).

return !!location.port; // true if there is a port, false otherwise
Phrogz
  • 296,393
  • 112
  • 651
  • 745
  • It works find but I I want to know what !! means in JS code? – Mahmoud R.Allam Apr 07 '16 at 03:48
  • `!foo` negates the value, turning it into a Boolean representing the opposite of the "truthy" value of `foo`. `!!foo` flips that Boolean back to represent the original "truthiness". Practically, this will turn `"8134"` into `true`, and turn `""` (empty string) into `false`. – Phrogz Apr 07 '16 at 05:46