当前位置:网站首页>版本号大小的判断方法
版本号大小的判断方法
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>
边栏推荐
- 有哪些可以投稿软件工程/系统软件/程序设计语言类外文期刊、会议?
- [数据可视化] 图表设计原则
- 报错:Client does not support authentication protocol requested by server; consider upgrading MySQL cli
- How to do patent mining, the key is to find patent points, in fact, it is not too difficult
- 成功解决raise TypeError(‘Unexpected feature_names type‘)TypeError: Unexpected feature_names type
- Jvm. Profiling tools (jconsole, jvisualvm, arthas, jprofiler, mat)
- 22/8/9 贪心问题合集
- 时间戳转换为日期格式、获取当前时间戳
- 如何破坏Excel文件,让其显示文件已损坏方法
- [Excel知识技能] 将数值格式数字转换为文本格式
猜你喜欢

详谈二叉搜索树

Which foreign language journals and conferences can be submitted for software engineering/system software/programming language?

Why do programming languages have the concept of variable types?

Apache Commons Configuration Remote Code Execution Vulnerability (CVE-2022-33980) Analysis & Reproduction

Single-chip human-computer interaction--matrix key

Design and implementation of flower online sales management system

“蔚来杯“2022牛客暑期多校训练营3 DF题解

异常:try catch finally throws throw

【考虫 六级英语】语法课笔记

【爬虫】scrapy创建运行爬虫、解析页面(嵌套url)、自定义中间件(设置UserAgent和代理IP)、自定义管道(保存到mysql)
随机推荐
Jvm.分析工具(jconsole,jvisualvm,arthas,jprofiler,mat)
PMP每日一练 | 考试不迷路-8.10(包含敏捷+多选)
Elastic scaling of construction resources
【redis】发布和订阅消息
报错:Client does not support authentication protocol requested by server; consider upgrading MySQL cli
C#使用计时器
YOLOv5的Tricks | 【Trick11】在线模型训练可视化工具wandb(Weights & Biases)
LeetCode_优先级队列_692.前K个高频单词
李彦宏拆墙交朋友,大厂“塑料友情”能否帮百度啃下硬骨头?
How to check if the online query suddenly slows down
HW-常见攻击方式和漏洞原理(2)
[Excel knowledge and skills] Convert numeric format numbers to text format
地下管廊可视化管理系统搭建
Web APIs BOM - A Comprehensive Case of Operating Browsers
只会懒汉式和饿汉式 你还不懂单例模式!
详解JDBC的实现与优化(万字详解)
HW-蓝队工作流程(1)
[Excel知识技能] 将“假“日期转为“真“日期格式
【.NET Core】使用 NPOI 读写Excel 文件
"NIO Cup" 2022 Nioke Summer Multi-School Training Camp 3 DF Problem Solving