search
HomeheadlinesHighly recommended: 20 ES6 tips worth collecting

This article organizes and shares ES6 tips, and compiled 20 frequently used ES6 code blocks for everyone. I hope you like it!

1. Disrupt the order of the array

Highly recommended: 20 ES6 tips worth collecting

##[Related recommendations:

javascript learning tutorial

2. Remove all characters except numbers

Highly recommended: 20 ES6 tips worth collecting

3. Reverse a string or word

Highly recommended: 20 ES6 tips worth collecting

4. Convert decimal to binary or hexadecimal

Highly recommended: 20 ES6 tips worth collecting

5. Merge multiple objects

Highly recommended: 20 ES6 tips worth collecting

6. ===<span style="font-size: 18px;"></span> and ==<span style="font-size: 18px;"></span># The difference between

Highly recommended: 20 ES6 tips worth collecting

#7. Destructuring assignment

Highly recommended: 20 ES6 tips worth collecting

8. Exchange the value of the variable

Highly recommended: 20 ES6 tips worth collecting

9-1. Judgment Palindrome string

9-Highly recommended: 20 ES6 tips worth collecting

Palindrome string: A string that is the same when written frontward or backward

9-2 Determine whether two strings are arranged with each other

9-Highly recommended: 20 ES6 tips worth collecting

Determine two characters Whether strings are permuted: Given two strings, whether one is a permutation of the other

10. Optional chaining operator

Highly recommended: 20 ES6 tips worth collecting

MDN:
Optional chain

operator ( ?. ) allows reading properties located deep in the connection object chain value without having to explicitly verify that each reference in the chain is valid. The function of the ?. operator is similar to the . chain operator. The difference is that when the reference is null (nullish) (null or undefined) will not cause an error, the short-circuit return value of this expression is undefined. When used with a function call, if the given function does not exist, returns undefined

For example:
if (res && res.data && res.data.success) {   
   //code} 
复制代码

is equivalent to:

if (res?.data?.success) {  // code}复制代码

11. Ternary operator

1Highly recommended: 20 ES6 tips worth collecting

12. Randomly select a value from the array

1Highly recommended: 20 ES6 tips worth collecting

13. Freezing Objects

1Highly recommended: 20 ES6 tips worth collecting

14. Delete duplicate elements from the array

1Highly recommended: 20 ES6 tips worth collecting

15. Keep the specified decimal places

1Highly recommended: 20 ES6 tips worth collecting

##16. Clear the array

17. Convert from <span style="font-size: 18px;">RGB</span> to <span style="font-size: 18px;">HEX</span>

1Highly recommended: 20 ES6 tips worth collecting

18. Get the maximum and minimum values ​​from the array

1Highly recommended: 20 ES6 tips worth collecting

19. Null value coalescing operator

Highly recommended: 20 ES6 tips worth collecting

##MDN:

Null value coalescing operator??) is a logical operator. When the operand on the left is null or undefined, it returns the operand on the right, otherwise it returns the left Operands.

20. Filter the values ​​in the array that are false<span style="font-size: 18px;"></span>

Highly recommended: 20 ES6 tips worth collecting

Source code

https://github.com/xieyezi/vuepress-blog/ blob/master/docs/front-end/ES6-20 frequently used techniques.md

Above, coding and drawing is very hard, I hope you don’t be stingy with your likes and likes. This is my biggest motivation to continue updating!

[Related video tutorial recommendations:

web front-end]

Statement
This article is reproduced at:weixin. If there is any infringement, please contact admin@php.cn delete

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Tools

MinGW - Minimalist GNU for Windows

MinGW - Minimalist GNU for Windows

This project is in the process of being migrated to osdn.net/projects/mingw, you can continue to follow us there. MinGW: A native Windows port of the GNU Compiler Collection (GCC), freely distributable import libraries and header files for building native Windows applications; includes extensions to the MSVC runtime to support C99 functionality. All MinGW software can run on 64-bit Windows platforms.

SublimeText3 English version

SublimeText3 English version

Recommended: Win version, supports code prompts!

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

VSCode Windows 64-bit Download

VSCode Windows 64-bit Download

A free and powerful IDE editor launched by Microsoft

DVWA

DVWA

Damn Vulnerable Web App (DVWA) is a PHP/MySQL web application that is very vulnerable. Its main goals are to be an aid for security professionals to test their skills and tools in a legal environment, to help web developers better understand the process of securing web applications, and to help teachers/students teach/learn in a classroom environment Web application security. The goal of DVWA is to practice some of the most common web vulnerabilities through a simple and straightforward interface, with varying degrees of difficulty. Please note that this software