Top JavaScript Snippets you should try once said

Tram Ho

Hello everyone, continuing today’s series of JS topics, I would like to share with you some interesting snippets to help us increase work efficiency, improve code quality. Let’s get started (go)

1. Random element in array

2. Round the number of decimals

3. Reverse the chain

4. Random number in a range of values

5. Random number types of integers in a range of values

6. Random hex color code

7. Convert radians to deg

8. Find the smallest element in the array

9. Find the largest element in the array

10. Find the min date

11. Find the max date

12. Compare 2 obj

13. Validate JSON

14. isBrowser

The following code is used to determine if the current running environment is a browser or not

15. Compare characters between two strings

16. Check the data type

17. Find elements that are similar between 2 arrays

18. Get data type

19. Calculate the distance between 2 days

20. forEachRight


Above are a few small snippets, but I believe they will help you a lot in the process of working with js.

If you find a good article, give me +1 upvote. If you like me, please press the follow button for more interesting things. Good luck !

Share the news now

Source : Viblo