当前位置:网站首页>版本号大小的判断方法
版本号大小的判断方法
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>
边栏推荐
- Mysql.慢Sql
- [21天学习挑战赛——内核笔记](五)——devmem读写寄存器调试
- 如何破坏Excel文件,让其显示文件已损坏方法
- Navicat 16-数据库工具
- Apache Commons Configuration远程代码执行漏洞(CVE-2022-33980)分析&复现
- 鲲鹏编译调试及原生开发工具基础知识
- Apache Commons Configuration Remote Code Execution Vulnerability (CVE-2022-33980) Analysis & Reproduction
- 什么是“门”电路(电子硬件)
- WebView2 通过 PuppeteerSharp 实现RPA获取壁纸 (案例版)
- Why do programming languages have the concept of variable types?
猜你喜欢

Web-based meal ordering system in epidemic quarantine area

容器技术真的是环境管理的救星吗?

EPro-PnP: Generalized End-to-End Probabilistic Perspective-n-Points for Monocular Object Pose Est...

Jvm. Profiling tools (jconsole, jvisualvm, arthas, jprofiler, mat)
![[GXYCTF2019]BabySQli](/img/8a/7500c0ee275d6ef8909553f34c99cf.png)
[GXYCTF2019]BabySQli

百战RHCE(第四十八战:运维工程师必会技-Ansible学习3-构建Ansible清单)

学习Apache ShardingSphere解析器源码(一)

ADC和DAC记录

地下管廊可视化管理系统搭建

WebView2 通过 PuppeteerSharp 实现RPA获取壁纸 (案例版)
随机推荐
鲲鹏编译调试及原生开发工具基础知识
[21-day learning challenge - kernel notes] (5) - devmem read and write register debugging
关于科研学习中的几个问题:如何看论文?如何评价工作?如何找idea?
Volatile和CAS
22/8/9 贪心问题合集
【openpyxl】只读模式、只写模式
[Excel知识技能] 将“假“日期转为“真“日期格式
报错:Client does not support authentication protocol requested by server; consider upgrading MySQL cli
[数据可视化] 图表设计原则
Elastic scaling of construction resources
“蔚来杯“2022牛客暑期多校训练营4 ADHK题解
YOLOv5的Tricks | 【Trick13】YOLOv5的detect.py脚本的解析与简化
力扣------用栈操作构建数组
SAP ABAP JSON 格式数据处理
什么是数组
[GXYCTF2019]BabySQli
Shell编程三剑客之sed
NOR FLASH闪存芯片ID应用之软件保护场景
91.(cesium之家)cesium火箭发射模拟
[Excel knowledge and skills] Convert "false" date to "true" date format