JavaScript Best Practices: Arrays

  • Use the literal syntax for array creation.
  • Use Array#push instead of direct assignment to add items to an array.
  • When you need to copy an array use Array#slice. jsPerf
  • To convert an array-like object to an array, use Array#slice.

Originally published at .