当前位置:网站首页>版本号大小的判断方法
版本号大小的判断方法
2022-08-11 00:36:00 【琴~~】
版本号大小的判断方法
<script>
function compareVersion(source, target) {
if (typeof source !== 'string' || typeof target !== 'string') return '传入的参数需要为字符串的形式'
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>
边栏推荐
- How to check if the online query suddenly slows down
- Navicat 16-数据库工具
- 【mysql】mysql分别按年/月/日/周分组统计数据
- 详谈二叉搜索树
- How to easily obtain the citation format of references?
- 【openpyxl】只读模式、只写模式
- WebView2 通过 PuppeteerSharp 实现RPA获取壁纸 (案例版)
- Mysql. Slow Sql
- Jvm. Profiling tools (jconsole, jvisualvm, arthas, jprofiler, mat)
- 只会懒汉式和饿汉式 你还不懂单例模式!
猜你喜欢
Shell 文本三剑客 Sed
工程师如何对待开源
ArcGIS Pro 创建tpk
复制带随机指针的链表——LeetCode
J9 Digital Theory: DAO governance is more like an ecological process: governance is native to the network and continues to evolve
Software Testing Certificate (1) - Software Evaluator
微信小程序自定义navigationBar
构建检测,无规矩不成方圆
BEVDepth: Acquisition of Reliable Depth for Multi-view 3D Object Detection 论文笔记
Elastic scaling of construction resources
随机推荐
【.NET Core】使用 NPOI 读写Excel 文件
② 关系数据库标准语言SQL 数据定义(创建、修改基本表)、数据更新(增删改)
【C语言】探索数据的存储(整形篇)
"NIO Cup" 2022 Nioke Summer Multi-School Training Camp 4 ADHK Problem Solving
In 22 years, the salary of programmers nationwide in January was released, only to know that there are so many with annual salary of more than 400,000?
How engineers treat open source
【经典排序】快速排序
Shell Text Three Musketeers Sed
百战RHCE(第四十八战:运维工程师必会技-Ansible学习3-构建Ansible清单)
16. 最接近的三数之和
SAS data processing technology (1)
工程师如何对待开源
HW-常见攻击方式和漏洞原理(2)
Mysql数据库安装配置详细教程
两个数组的交集
Volatile和CAS
Navicat 16-数据库工具
有哪些可以投稿软件工程/系统软件/程序设计语言类外文期刊、会议?
Which foreign language journals and conferences can be submitted for software engineering/system software/programming language?
Mysql.慢Sql