These are a collection of tips and tricks you can use to improve the performance and readability of your code.
By wrapping code that can fail in try-catch, we can react to and recover from any errors that happen.
We can’t access object properties using dot notation if the property name is dynamic. In those situations, we can use bracket notation instead.
When splitting strings, the sequence of characters we split at does not appear in the result. We can get all letters by splitting at the empty string.
When the if-branch already returns, we can omit the keyword else. The execution will only go beyond the if-branch if it doesn’t apply anyways.
Instead of passing a list of parameters to a function, we can pass it an object. That way, we have to explicitly label each parameter we pass to it.
If an arrow function immediately returns a value, we don’t have to write the return keyword. The function will still implicitly return that value.
We can hide the repetition in a function’s parameters in a higher-order function.
Template literals allow us to put the values of variables, the results of calculations, and even return values of function calls into strings.