当前位置:网站首页>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
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
}
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 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
版权声明
本文为[Front end talent]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/04/202204231449329431.html
边栏推荐
- vscode中文插件不生效问题解决
- UML学习_day2
- 如何打开Win10启动文件夹?
- First acquaintance with STL
- [NLP] HMM hidden Markov + Viterbi word segmentation
- One of the advanced applications of I / O reuse: non blocking connect -- implemented using select (or poll)
- Resolve the conflict between computed attribute and input blur event
- 每日一题-LeetCode396-旋转函数-递推
- Outsourcing for four years, abandoned
- Thread synchronization, life cycle
猜你喜欢

博睿数据携手F5共同构建金融科技从代码到用户的全数据链DNA

Progress in the treatment of depression

What is the effect of Zhongfu Jinshi wealth class 29800? Walk with professional investors to make investment easier

MySQL报错packet out of order

we引用My97DatePicker 实现时间插件使用
![[untitled]](/img/6c/df2ebb3e39d1e47b8dd74cfdddbb06.gif)
[untitled]

每日一题-LeetCode396-旋转函数-递推

SVN详细使用教程

MySQL error packet out of order

你还不知道责任链模式的使用场景吗?
随机推荐
Alexnet model
Pnpm installation and use
Leetcode153 - find the minimum value in the rotation sort array - array - binary search
面试官:说一下类加载的过程以及类加载的机制(双亲委派机制)
GIS数据处理-cesium中模型位置设置
Advanced application of I / O multiplexing: Processing TCP and UDP services at the same time
Daily question - leetcode396 - rotation function - recursion
帧同步 实现
Svn detailed use tutorial
拼接hql时,新增字段没有出现在构造方法中
PCIe X1 插槽的主要用途是什么?
分享 20 个不容错过的 ES6 的技巧
Frame synchronization implementation
Vscode Chinese plug-in doesn't work. Problem solving
ASEMI超快恢复二极管与肖特基二极管可以互换吗
多语言通信基础 06 go实现grpc的四种数据流模式实现
Select receives both normal data and out of band data
Swift - Literal,字面量协议,基本数据类型、dictionary/array之间的转换
A good tool: aardio
【STC8G2K64S4】比较器介绍以及比较器掉电检测示例程序