当前位置:网站首页>How to determine the size of the version number
How to determine the size of the version number
2022-08-11 00:50:00 【piano~~】
How to determine the size of the version number
<script>
function compareVersion(source, target) {
if (typeof source !== 'string' || typeof target !== 'string') return 'The parameter passed in needs to be in the form of a string'
const sourceArr = source.split('.');
const targetArr = target.split('.');
for (let index = 0; index < sourceArr?.length; index++) {
if (sourceArr[index] !== targetArr[index]) {
if (sourceArr[index] > targetArr[index]) {
return 1
}
return -1
}
}
}
const a = compareVersion('1.0.3', '1.0.5');
console.log(a, 'a is');
const b = compareVersion('1.0.7', '1.0.5');
console.log(b)
</script>
边栏推荐
猜你喜欢
随机推荐
成功解决TypeError: can‘t multiply sequence by non-int of type ‘float‘
EN 12467纤维水泥平板产品—CE认证
Some Experiences of Embedded Software Logging
YOLOv5的Tricks | 【Trick10】从PyTorch Hub加载YOLOv5
【考虫 六级英语】语法课笔记
Use mysql statement to operate data table (table)
Mysql database installation and configuration detailed tutorial
How engineers treat open source
单片机人机交互--矩阵按键
Dump文件生成,内容,以及分析
二维数组实战项目--------《扫雷游戏》
[21 Days Learning Challenge] Half Insertion Sort
SQL语句--获取数据库表信息,表名、列名、描述注释等
Shell编程三剑客之sed
Lens filter---about day and night dual-pass filter
16. 最接近的三数之和
虚拟电厂可视化大屏,深挖痛点精准减碳
"NIO Cup" 2022 Nioke Summer Multi-School Training Camp 4 ADHK Problem Solving
小程序onPageNotFound的坑
WinForm(五)控件和它的成员