There are cases where you want the destructured variable to have a different name than the property name.
Transform the items in an array and create a new one
Iterate through each item in an array, transform it, and return a new array.
Filter out matching array elements
Filters out the elements of an array that have one of the specified values.
Count elements in an array
Two ways to count the total number of the same elements in a single array.
Create a new array from an existing one
Create a new array from an existing one, or transform an array-like object (like a NodeList) into an array.
Capitalize the first letter of every word in a string
Use String.prototype.replace() to match the first character of each word and String.prototype.toUpperCase() to capitalize it.
Get unique values in an array
Source https://github.com/JSsnippets/JavaScript-snippets
Delete, replace, and add items to an array at specific indexes
The Array.splice() method accepts three arguments: start, delete, and items. The first, start, is the index of the item you want to modify in the array. It’s the only required argument. The second, delete, is the number of items to delete from the array. If you omit this argument, the Array.splice() method will remove every item from the start index on. If you set it to 0, […]
Two ways to remove a specific item in an array
Remove a specific item in an array either the mutating way or the non-mutating way. Source https://github.com/JSsnippets/JavaScript-snippets
Calculate the difference (in hours) between two dates
Subtract the two Date objects and divide by the number of milliseconds in an hour to get the difference (in hours) between them. Source https://www.30secondsofcode.org/js/s/get-hours-diff-between-dates