Today I Learned

hashrocket A Hashrocket project

Slicing arguments into an array.

The arguments keyword in javascript is not of type Array, but can be turned into an Array easily by using the slice function of the Array prototype.

function varargs() {
  return Array.prototype.slice.apply(arguments);

> varargs(1, 2, 3);
[1, 2, 3]
See More #javascript TILs
Looking for help? At Hashrocket, our JavaScript experts launch scalable, performant apps on the Web, Android and iOS. Contact us and find out how we can help you.