↓ Ir para o conteúdo principal

← todas as notas

📎 Webclip

10 Awesome JavaScript Shorthands

The article presents ten JavaScript shortcuts that replace longer patterns with shorter ones. It focuses on array merging and cloning, destructuring, template literals, loop forms, object lookup with find(), numeric conversion with unary +, and defaulting with ||.

Reading notes
#

  • Arrays can be merged with the ES6 spread operator instead of concat() or unshift.apply().
  • Arrays can be cloned with spread syntax instead of slice().
  • Destructuring assignment can unpack array values into variables in one line.
  • Template literals let you embed expressions inside backticks with ${...}.
  • for...of and arrow functions can shorten common loop patterns.
  • find() can return the matching object in an array by property value.
  • A leading + can convert a numeric string to an integer.
  • || can return a fallback value when the first value is falsy.