This website collects cookies to deliver better user experience

How to check if a number or a string is a valid port number in JavaScript?