How do I use javascript to compare the size of the starting ip and ending ip of the ipv6 format?

1, node environment?
2, non-node environment?
because the actual work is jquery+bootstrap, it is best to implement a pure js
3, please consider:: case, 0234 omitted from 234, etc.

Aug.09,2021

IPV6 is made up of four-digit hexadecimal numbers, which is actually numeric.

parseInt("AAAA",16)
43690

first segment the IP.
for example:


ASCII

const ipv6 = 'CDCD:910A:2222:5498:8475:1111:3900:2020'
let blocks = ipv6.toUpperCase().split(':')
console.log(a[0] > a[7])

there is no need to distinguish between js running environments

Menu