Favorite Javascript Methods?

I thought it might be cool and educational to see what everyone’s go-to javascript code/methods are. Particularly if you don’t see it used all that much. Some javascript code that I abuse is:

Object.assign(), <-- very nice for putting together objects without needing to declare variables
Array.prototype.every, <-- quick way of checking that everything in an array passes a test (similar to filter)
Promise.all() <-- Nice way of doing something when an array of promises all resolve
RegExp() <-- converts a string to a regular expression, very useful in you want your regex pattern to be variable
1 Like