1

4 Tips for JavaScript 2021 to write optimized code

 3 years ago
source link: https://dev.to/animeshdhanuk/4-tips-for-javascript-2021-to-write-optimized-code-3ih
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
neoserver,ios ssh client
Cover image for 4 Tips for JavaScript 2021 to write optimized code

4 Tips for JavaScript 2021 to write optimized code

Jun 11

・2 min read

tips for JavaScript 2021 to write optimized code

JavaScript is the front-hand language as we know. JavaScript is using for web designing, mobile apps, game development, crate web servers, and JavaScript is WebSite Scripting Language(WSSL). That's one of the most used languages by developers, programmers, and coders.

1. Use Logical Assignment Operators

Now, In JavaScript 2021 logical operators and assignment operators are combined, so you can use both in the same syntax as below. And That's one of the most used tips for JavaScript 2021 to write optimized code.

OR Operator

The logical OR assignment (X ||= Y) operator only assigns if X is false.

AND Operator

The logical AND assignment (X &&= Y) operator only assigns if X is true.

2. Use Numeric Separators

This is one of the most used operators by developers and programmers when they have a large amount of numbers. When using a separator in number it looks better than an unseparated number. This is one of the best tips for JavaScript 2021 to write optimized code.

3. Use Replace All

The replaceAll() method returns a new string with all matches. It returns any pattern that can be a string. The original string is left unchanged. The syntax of this operator is replaceAll(regexp, newSubstr). That's one of the most used tips for JavaScript 2021 to write optimized code.

4. Use Promise.Any()

The promise.any() method is to resolve your promise() as soon as which is passed by you. If no promise is passed then it returns promise is rejected with an error. That's one of the best tips for JavaScript 2021 to write optimized code.

I Hope You Enjoy The Above Tips. Thank For Reading...

Read More


About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK