function compareVersion(x,y){ let xArr = x.split('.'), yArr = y.split('.'), len = xArr.length > yArr.length ? xArr.length : yArr.length; for(let i = 0;i < len;i++){ let xItem = xArr[i],yItem = yArr[i]; if(xItem > yItem){ return 1 }else if(xItem < yItem){ return -1 } } return 0 }