当前位置:网站首页>Share 20 tips for ES6 that should not be missed
Share 20 tips for ES6 that should not be missed
2022-04-23 14:53:00 【Front end talent】
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
github
On , 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 ) (null
perhapsundefined
) 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
}
amount to :
if (res?.data?.success) {
// 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 arenull
perhapsundefined
when , 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
版权声明
本文为[Front end talent]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/04/202204231449329431.html
边栏推荐
- [servlet] detailed explanation of servlet (use + principle)
- Explain TCP's three handshakes in detail
- Interviewer: let's talk about the process of class loading and the mechanism of class loading (parental delegation mechanism)
- Do (local scope), initializer, memory conflict, swift pointer, inout, unsafepointer, unsafebitcast, success
- Svn detailed use tutorial
- Daily question - leetcode396 - rotation function - recursion
- What is the effect of Zhongfu Jinshi wealth class 29800? Walk with professional investors to make investment easier
- 封面和标题中的关键词怎么写?做自媒体为什么视频没有播放量
- pnpm安装使用
- QT Detailed explanation of pro file
猜你喜欢
Role of asemi rectifier module mdq100-16 in intelligent switching power supply
线程同步、生命周期
编程哲学——自动加载、依赖注入与控制反转
eolink 如何助力远程办公
1n5408-asemi rectifier diode
capacitance
L'externalisation a duré quatre ans.
thinkphp5+数据大屏展示效果
在游戏世界组建一支AI团队,超参数的多智能体「大乱斗」开赛
Provided by Chengdu control panel design_ It's detailed_ Introduction to the definition, compilation and quotation of single chip microcomputer program header file
随机推荐
【NLP】HMM隐马尔可夫+维特比分词
What is the main purpose of PCIe X1 slot?
【JZ46 把数字翻译成字符串】
When splicing HQL, the new field does not appear in the construction method
Swift: entry of program, swift calls OC@_ silgen_ Name, OC calls swift, dynamic, string, substring
ASEMI整流模块MDQ100-16在智能开关电源中的作用
MDS55-16-ASEMI整流模块MDS55-16
epoll 的EPOLLONESHOT 事件———实例程序
Outsourcing for four years, abandoned
Epoll's et, lt working mode -- example program
Explain TCP's three handshakes in detail
Leetcode exercise - 396 Rotation function
thinkphp5+数据大屏展示效果
Sword finger offer II 019 Delete at most one character to get palindrome (simple)
Is asemi ultrafast recovery diode interchangeable with Schottky diode
we引用My97DatePicker 实现时间插件使用
pnpm安装使用
1-初识Go语言
Arduino for esp8266串口功能简介
Progress in the treatment of depression