An Interest In:
Web News this Week
- April 19, 2024
- April 18, 2024
- April 17, 2024
- April 16, 2024
- April 15, 2024
- April 14, 2024
- April 13, 2024
August 27, 2021 03:39 am GMT
Read More: 10 Magical JavaScript Tips for Every Web Developer
Original Link: https://dev.to/tips_tricks/10-magical-javascript-tips-for-every-front-end-developer-4jlg
10 Magical JavaScript Tips For Every Front-end Developer
In this article, we will discuss the 15 useful JavaScript tips for every web developer to save their valuable and precious time.
I am always ready to learn although I do not always like being taught
Winston Churchill
Tip 1. Flatten the array of the array
This tip will help you to flatten a deeply nested array of arrays by usingInfinity
inflat
.
var array = [123, 500, [1, 2, [34, 56, 67, [234, 1245], 900]], 845, [30257]]//flatten array of array
array.flat(Infinity)// output:
// [123, 500, 1, 2, 34, 56, 67, 234, 1245, 900, 845, 30257]
Tip 2. Easy Exchange Variables
You probably swap the two variables using a third variabletemp
. But this tip will show you a new way to exchange variables using destructuring.
//example 1var a = 6;
var b = 7;[a,b] = [b,a]console.log(a,b) // 7 6
Read More: 10 Magical JavaScript Tips for Every Web Developer
Original Link: https://dev.to/tips_tricks/10-magical-javascript-tips-for-every-front-end-developer-4jlg
Share this article:
Tweet
View Full Article
Dev To
An online community for sharing and discovering great ideas, having debates, and making friendsMore About this Source Visit Dev To