What are the 19 JavaScript abbreviation skills that must be met by well-paid web front-end engineers?
What are the 19 JavaScript abbreviation skills that must be used by well-paid web front-end engineers? in view of this problem, this article introduces the corresponding analysis and solutions in detail, hoping to help more partners who want to solve this problem to find a more simple and feasible way.
1. Ternary operator
When you want to write if...else statements, use ternary operators instead.
Abbreviation:
It can also be nested.
two。 Shorthand method of short circuit evaluation
When assigning another value to a variable, you want to make sure that the source value is not null,undefined or null. You can write an if statement with multiple conditions.
Or you can use the short-circuit evaluation method:
Here the editor has built a front-end learning and exchange QQ group: 132667127, I have sorted out the latest front-end materials and advanced development tutorials, if you want, you can join the group to learn and communicate together.
3. Shorthand method for declaring variables
Abbreviation method:
The abbreviation method of 4.if existence condition
Abbreviation:
The two statements are equal only if likeJavaScript is true.
If the judgment value is not true, you can do this:
Abbreviation:
Shorthand method of 5.JavaScript loop
Abbreviation: for (letindexinallImgs) can also use Array.forEach:
6. Short circuit evaluation
To assign a value to a variable by determining whether its value is null or undefined, you can:
Abbreviation:
7. Decimal index
When you need to write a number with a lot of 00:00 (such as 10000000), you can use the 1e7 instead of this number: for (leti=0;i)