端口号为整数,范围在0~65535之间
function isLegalPort(port){
if((typeof port !== 'number' && typeof !== 'string' ) || (typeof port === 'string' && !port.trim().length)) return false
return +port === (+port >>> 0) && +port <= 0xFFFF
}
function isLegalPort(port){
if((typeof port !== 'number' && typeof !== 'string' ) || (typeof port === 'string' && !port.trim().length)) return false
return +port === (+port >>> 0) && +port <= 0xFFFF
}
本文标题:判断合法的端口号
本文链接:https://www.haomeiwen.com/subject/hodsxqtx.html
网友评论