当前位置:网站首页>js小技巧
js小技巧
2022-07-27 04:32:00 【万事胜意sy】
清空数组

从数组中获取最大值和最小值

空值合并运算符

MDN: 空值合并操作符(??)是一个逻辑操作符,当左侧的操作数为 null 或者 undefined 时,返回其右侧操作数,否则返回左侧操作数。
可选链操作符

MDN: 可选链操作符( ?. )
允许读取位于连接对象链深处的属性的值,而不必明确验证链中的每个引用是否有效。?. 操作符的功能类似于 . 链式操作符,不同之处在于,在引用为空(nullish ) (null 或者 undefined) 的情况下不会引起错误,该表达式短路返回值是 undefined。与函数调用一起使用时,如果给定的函数不存在,则返回 undefined
交换变量的值

保留指定位小数

清空数组

过滤数组中值为 false 的值

从数组中随机选择一个值

删除数组重复的元素

边栏推荐
- VSCode开启Pull Request更新代码分支可视化新篇章
- Head detached from origin/... Causes push failure
- Horizon sunrise X3 PI (IV) running on board (unfinished)
- Use unity to build a WordArt system
- 【C语言】动态内存管理
- Huawei's entry into the commercial market: due to the trend, there are many challenges
- Effect Hook
- Solution to the third game of 2022 Hangzhou Electric Multi school league
- 第4章 Bean对象的作用域以及生命周期
- 结构型模式-适配器模式
猜你喜欢

【C语言】自定义类型详解(结构体+枚举+联合)

使用Unity做一个艺术字系统

Chapter 4 scope and life cycle of bean object

【独立站建设】跨境电商出海开网店,首选这个网站建设!

Dynamic routing configuration
![[day02] Introduction to data type conversion, operators and methods](/img/81/e2c49a4206e5d0d05308a1fc881626.png)
[day02] Introduction to data type conversion, operators and methods

F - Pre-order and In-order(Atcoder 255)
![[construction of independent stations] this website is the first choice for cross-border e-commerce companies to open online stores at sea!](/img/26/22597a7ece0431a4e54703945a775c.jpg)
[construction of independent stations] this website is the first choice for cross-border e-commerce companies to open online stores at sea!

IP第十四天笔记
![Shell的正则表达式入门、常规匹配、特殊字符:^、$、.、*、字符区间(中括号):[ ]、特殊字符:\、匹配手机号](/img/31/ed0d8c1a5327059f2de7493bec1c6c.png)
Shell的正则表达式入门、常规匹配、特殊字符:^、$、.、*、字符区间(中括号):[ ]、特殊字符:\、匹配手机号
随机推荐
如何做数据平滑迁移:双写方案
Pinia uses the whole process, including state, actions, getters, and how to deconstruct, respond, and various methods used by actions
好用移动APP自动化测试框架哪里找?收藏这份清单就好了!
RSA asymmetric encryption and decryption signature verification tool
Two way republication experiment
干货 | 独立站运营怎么提高在线聊天客户服务?
Differences and uses of SRAM, DRAM, SDRAM and DDR
【动态规划百题强化计划】11~20(持续更新中)
Anonymous named pipes, understanding and use of interprocess communication in shared memory
[dynamic planning hundred questions strengthening plan] 11~20 (continuously updating)
结构型模式-外观(Facade)模式
Effect Hook
P1438 boring sequence line segment tree + difference
Digital integrated circuit: MOS tube device chapter (I)
安全第四次课后练习
缓存读写策略:CacheAside、Read/WriteThrough及WriteBack策略
结构型模式-适配器模式
Structural mode - adapter mode
How to set user-defined display for Jiaming Watch
Introduction to regular expressions of shell, general matching, special characters: ^, $,., * Character range (brackets): [], special characters: \, matching mobile phone number