比较版本号大小
const compareVersion = (source = '10.2.3.beta', target = '10.2.13') => { const targetArray = target.split('.') const sourceArray = source.split('.') const len = targetArray.length > sourceArray.length ? targetArray.length : sourceArray.length const getValue = (value) => { return value ? Number.isNaN(Number(value)) ? value : Number(value) : '' } for (let i = 0; i < len; i++) { const tv = getValue(targetArray[i]) const sv = getValue(sourceArray[i]) if (sv > tv) { return -1 } else if (sv < tv) { return 1 } } return 0 }
以自己现在的努力程度,还没有资格和别人拼天赋