当前位置:网站首页>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>
边栏推荐
- 力扣------值相等的最小索引
- Distributed. Performance optimization
- 分库分表ShardingSphere-JDBC笔记整理
- Only lazy and hungry. You still don't understand the singleton pattern!
- word 设置标题前分页
- apache+PHP+MySQL+word press,安装word press时页面报错?
- "NIO Cup" 2022 Nioke Summer Multi-School Training Camp 4 ADHK Problem Solving
- C#-委托的详细用法
- SQL语句--获取数据库表信息,表名、列名、描述注释等
- Pico 4更多参数曝光:Pancake+彩色透视,还有Pro版本
猜你喜欢
Only lazy and hungry. You still don't understand the singleton pattern!
从0开始设计JVM ,忘记名词跟上思路一次搞懂
[Excel knowledge and skills] Convert "false" date to "true" date format
WinForm(五)控件和它的成员
Single-chip human-computer interaction--matrix key
apache+PHP+MySQL+word press,安装word press时页面报错?
Apache Commons Configuration远程代码执行漏洞(CVE-2022-33980)分析&复现
力扣------使用最小花费爬楼梯
HW-蓝队工作流程(1)
Two-dimensional array combat project -------- "Minesweeper Game"
随机推荐
分库分表ShardingSphere-JDBC笔记整理
只会懒汉式和饿汉式 你还不懂单例模式!
YOLOv5的Tricks | 【Trick13】YOLOv5的detect.py脚本的解析与简化
MSTP——多生成树(案列+配置)
Word set before the title page
rhel7.0解决yum无法使用(system is not registered to Red Hat Subscription Management)
Jvm.分析工具(jconsole,jvisualvm,arthas,jprofiler,mat)
地下管廊可视化管理系统搭建
单片机人机交互--矩阵按键
PMP每日一练 | 考试不迷路-8.10(包含敏捷+多选)
什么是数组
C# using timer
【21天学习挑战赛】折半插入排序
HW-常见攻击方式和漏洞原理(2)
[Excel knowledge and skills] Convert "false" date to "true" date format
关于科研学习中的几个问题:如何看论文?如何评价工作?如何找idea?
Single-chip human-computer interaction--matrix key
ADC和DAC记录
微信小程序内部A页面向内嵌H5页面跳转,并且传参
The SAP ABAP JSON format data processing