[Front-end | Code Optimization]——Part 1: List of common front-end code optimization points
Language
2023-10-03 16:44:23
views: null
List front-end code optimization points
1. Use 模板字符串
instead of string concatenation
2. Use 解构赋值
to avoid repeated use of item.xx1, item.xx2
3. Determine whether an attribute in the array has a value.some()
4. includes()
Used to determine whether an array contains an element - (can be used to avoid multiple repeated conditional statements)
5. Create a new array and array.form()
replace it withfor循环 + push()
6. Use [ filter
] + [ includes
] to return the specified item instead of map+push
7. One of the differences between map and forEach is map可以返回新数组
that you can use return
or ()
to return
8. Determine and obtain duplicate items new Set + filter + indexOf
- (can be used to prompt to mark duplicate item data)
Origin blog.csdn.net/sunshineTing2/article/details/132063513