当前位置:网站首页>20 not to be missed ES6 tips
20 not to be missed ES6 tips
2022-06-24 07:19:00 【zz_ jesse】
Preface
Hello everyone , I am a xieyezi, Long time no see , I'm back in the Nuggets again , This time, I sorted out 20 A high frequency of use ES6 Code block , Hope you enjoy it
The detailed comments and specific usage of the code are in my
githubOn , The source code is connected at the bottom
1. Disorder array order

2. Remove all characters except numbers

3. Invert a string or word

4. Convert decimal to binary or hexadecimal

5. Merge multiple objects

6. === and == The difference between

7. Deconstruct assignment

8. Exchange the values of variables

9-1. Judge palindrome string

Palindrome string : Write the same string forward and reverse ( Special thanks \@ Floating garret master [1] Corrigendum )
9-2 Judge whether the two strings are arranged with each other

Judge whether the two strings are arranged with each other : Given two strings , Whether one is the arrangement of another
10. Optional chain operator

MDN: Optional chain The operator (
?.) Allows you to read the value of an attribute deep in the chain of connected objects , Instead of explicitly verifying that each reference in the chain is valid .?.The function of the operator is similar to.Chain operators , The difference is , The reference is empty (nullish ) (nullperhapsundefined) It doesn't cause errors , The short-circuit return value of this expression isundefined. When used with function calls , If the given function does not exist , Then return toundefined
for example :
if (res && res.data && res.data.success) {
//code
}
Copy code amount to :
if (res?.data?.success) {
// code
}
Copy code 11. Ternary operator

12. Randomly select a value from the array

13. Freeze objects

14. Delete duplicate elements of the array

15. Retention refers to the positioning of decimals

16. Empty array

17. from RGB Convert to HEX

18. Get the maximum and minimum values from the array

19. Null merge operator

MDN: Null merge operator (
??) It's a logical operator , When the operands on the left arenullperhapsundefinedwhen , Returns its right-hand operand , Otherwise, return the left-hand operand .
20. The value in the filter array is false Value

Source code
20 A must not miss ES6 skill [2]
above , Codeword mapping is hard , Please don't be stingy with your praise , Your praise is the biggest driving force for me to continue to update !
About this article
author :Xieyezi
https://juejin.cn/post/7083145771461115941
边栏推荐
- Laravel document reading notes -laravel str slug() function example
- 自动化测试是什么?什么软件项目适合自动化测试?
- How do I turn off win10 automatic update? What are the good ways?
- 软件性能测试分析与调优实践之路-JMeter对RPC服务的性能压测分析与调优-手稿节选
- 【pointNet】基于pointNet的三维点云目标分类识别matlab仿真
- JVM调试工具-jstack
- Big factories are not the only way to measure ability. The three years' experience of Shangcai's graduation
- The initial user names and passwords of Huawei devices are a large collection that engineers involved in Huawei business should keep in mind and collect!
- [Yugong series] June 2022 asp Basic introduction and use of cellreport reporting tool under net core
- Canal安装配置
猜你喜欢

超宽带脉冲定位方案,UWB精准定位技术,无线室内定位应用
![[cloud based co creation] overview of the IOT of Huawei cloud HCIA IOT v2.5 training series](/img/80/1be6a87639ac8da41bc881b3341646.png)
[cloud based co creation] overview of the IOT of Huawei cloud HCIA IOT v2.5 training series

JVM调试工具-jvisualvm

大厂不是衡量能力的唯一出路,上财学姐毕业三年的经验分享

简单使用Modbus转BACnet网关教程

JVM debugging tool -jmap

MAUI使用Masa blazor组件库

【图像融合】基于像素显着性结合小波变换实现多焦点和多光谱图像融合附matlab代码

在终端pip install xxx但在pycharm却no module named xxx

利用微搭低代码实现级联选择
随机推荐
MySQL enable binlog
【帧率倍频】基于FPGA的视频帧率倍频系统verilog开发实现
Spark parameter tuning practice
On update current in MySQL_ TIMESTAMP
JSON online parsing and the structure of JSON
Implementation and usage analysis of static pod
One year since joining Tencent
RealNetworks vs. Microsoft: the battle in the early streaming media industry
JVM调试工具-jps
Hyperledger fabric ledger snapshot - fast data synchronization
Fine! Storage knowledge is a must for network engineers!
Spark项目打包优化实践
Huawei Cloud Database Advanced Learning
简单使用Modbus转BACnet网关教程
面渣逆袭:MySQL六十六问,两万字+五十图详解
1. go deep into tidb: see tidb for the first time
Cisco router configuration notes: static routing, rip, OSPF, principles combined with experiments, worth a visit!
Research on redis High Availability Mechanism
Intelligent Vision Group A4 paper recognition example
Computing power and intelligence of robot fog