1. Get Unique Values of an Array
You can easily get an array of unique values through this trick. Let’s understand it with the help of an example.
Filter False Values
This trick will help you filter false values(o, undefined, null, false, etc.) out of an array. This is a kind of a secret trick as not many people are aware of it.
2. Create Empty Objects
3. Merge Objects
4. Remove Duplicate Items
Students can easily remove duplicate items from an array by using Sets along with a Spread operator. Here’s how to do it.
const removeDuplicateItems = arr => [...new Set(arr)];
removeDuplicateItems([42, 'foo', 42, 'foo', true, true]);//=> [42, "foo", true]
5. Require Function Parameters
You can’t just miss this awesome trick for requiring values be passed for a given argument.
6. Destructure Alias
7. Get Query String Parameters
Students write gross regular expressions to get query strings however, they can enter the URL Search Params API too. This will save their time as well as is easy to do. Just try writing this simple code.
8. Append an Array to Another Array
9. Removing an Item from Array
Students generally use DELETE command to remove an item from the array. However, this command replaces the item with undefined instead of completely removing it. You can use the SPLICE command instead. Here’s how to do it.
Till then, keep programming!
Topic CreationUSD 3.87
Unlimited RevisionsUSD 20.67
Get All These Features of