I write a simple function in javascript to parse an IP address string and returns an array of integers that represents four octets:
function parseIP(str) {
octets = str.split('.');
console.log(octets);
return octets.map(parseInt);
}
console.log(parseIP("0.0.0.0"));
To my surprise, the function returns [0, Nan, 0, 0]
instead of [0, 0, 0, 0]
. Any idea why it behaves this way?