当前位置:网站首页>版本号大小的判断方法
版本号大小的判断方法
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>
边栏推荐
- [Excel知识技能] 将文本型数字转换为数值格式
- How to build speed, speed up again
- nodejs项目连接mysql数据库
- Apache Commons Configuration远程代码执行漏洞(CVE-2022-33980)分析&复现
- 二维数组实战项目--------《扫雷游戏》
- 【.NET Core】使用 NPOI 读写Excel 文件
- 16. Sum of the nearest three numbers
- [21-day learning challenge - kernel notes] (5) - devmem read and write register debugging
- 只会懒汉式和饿汉式 你还不懂单例模式!
- Only lazy and hungry. You still don't understand the singleton pattern!
猜你喜欢

Ali P7 bask in January payroll: hard to fill the, really sweet...

给肯德基打工的调料商,年赚两亿

Qt入门(六)——抽奖系统的实现

rhel7.0解决yum无法使用(system is not registered to Red Hat Subscription Management)

Mysql. Slow Sql

Web APIs BOM- 操作浏览器之综合案例

How to easily obtain the citation format of references?

只会懒汉式和饿汉式 你还不懂单例模式!

【C语言】探索数据的存储(整形篇)

I caught a 10-year-old Ali test developer, and after talking about it, I made a lot of money...
随机推荐
“蔚来杯“2022牛客暑期多校训练营2 DGHJKL题解
Why do programming languages have the concept of variable types?
力扣------用栈操作构建数组
成功解决raise TypeError(‘Unexpected feature_names type‘)TypeError: Unexpected feature_names type
BEVDepth: Acquisition of Reliable Depth for Multi-view 3D Object Detection 论文笔记
Single-chip human-computer interaction--matrix key
EN 12467纤维水泥平板产品—CE认证
input输入框超出部分用省略号表示以及判断内容是否有超出(PC端)
WebView2 通过 PuppeteerSharp 实现RPA获取壁纸 (案例版)
Pagoda Test-Building PHP Online Mock Exam System
两个链表的第一个公共节点——LeetCode
力扣------值相等的最小索引
16. Sum of the nearest three numbers
地下管廊可视化管理系统搭建
Go项目配置管理神器之viper使用详解
2022.8.10-----leetcode.640
@Autowired注入RedisCache报错空指针
二维数组实战项目--------《扫雷游戏》
【21天学习挑战赛】折半插入排序
异常:try catch finally throws throw