Authors Devesh
A thread🧵
Never declare variables inside a for
When executing lengthy 'for' statements, don't make the engine work any harder than it must.
— Devesh (@Deveshb15) June 16, 2021
It is highly inefficient to traverse the DOM to find the 'container'.
That's the reason you must always declare a variable outside the 'for' loop! pic.twitter.com/kArmUVSV78
Copy to
JavaScript Tip\U0001f530
— Devesh (@Deveshb15) May 10, 2021
Copy to Clipboard button in JavaScript!\xa9 pic.twitter.com/VLgM8C99ER
Use "splice" instead of
Use splice instead of using delete to delete an item from an array. Using delete replaces the item with undefined instead of removing it from the array.
— Devesh (@Deveshb15) July 2, 2021
The delete method should be used to delete an object property. pic.twitter.com/ntMLWNVVFN
Array of unique
Create an array of unique values in JavaScript i.e. remove duplicates\U0001f530
— Devesh (@Deveshb15) May 31, 2021
We can create a new array containing only the unique values by using the Set object with the Spread operator. pic.twitter.com/3epttOha44