当前位置:网站首页>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
边栏推荐
- 【WordPress建站】5. 设置代码高亮
- Clickhouse source code note 6: exploring the sorting of columnar storage systems
- 捏脸师: 炙手可热的元宇宙造型师
- Leetcode probability interview shock series 11~15
- JVM debugging tool -jstack
- Serviceworker working mechanism and life cycle: resource caching and collaborative communication processing
- Hyperledger fabric ledger snapshot - fast data synchronization
- System design: partition or data partition
- [problem solving] the connection to the server localhost:8080 was referred
- 华为云数据库进阶学习
猜你喜欢

Counter attack of flour dregs: MySQL 66 questions, 20000 words + 50 pictures

如何删除/选择电脑上的输入法

Computing power and intelligence of robot fog

You have a chance, here is a stage

Arduino raised $32million to enter the enterprise market

Summary of 2022 blue team HW elementary interview questions

Typora charges? Build vs Code markdown writing environment

学会使用楼宇控制系统BACnet网关没那么难

【图像融合】基于伪 Wigner 分布 (PWD) 实现图像融合附matlab代码

Open source and innovation
随机推荐
Serviceworker working mechanism and life cycle: resource caching and collaborative communication processing
展锐芯片之GPU频率
两个链表的第一个公共节点_链表中环的入口(剑指offer)
.NET7之MiniAPI(特别篇) :Preview5优化了JWT验证(上)
Canal安装配置
Prefix and topic training
Maui uses Masa blazor component library
. Net7 miniapi (special part):preview5 optimizes JWT verification (Part 1)
学会使用楼宇控制系统BACnet网关没那么难
OMX initialization process
大厂不是衡量能力的唯一出路,上财学姐毕业三年的经验分享
FreeRTOS MPU makes the system more robust!
Development of IOT device end - establishment of development environment
EasyDSS_ The dash version solves the problem that the RTSP source address cannot play the video stream
JVM debugging tool -jps
电脑如何打开软键盘,教大家Win10如何打开软键盘的方法
【帧率倍频】基于FPGA的视频帧率倍频系统verilog开发实现
System design: partition or data partition
捏脸师: 炙手可热的元宇宙造型师
Go operation SQLite code error