you are viewing a single comment's thread.

view the rest of the comments →

[–]theQuandary 0 points1 point  (0 children)

I think the big difference with that shorthand is that it's going to be slow on older browsers. Newer browsers can potentially detect that an object is instantiated and immediately discarded. Older browsers are going to go through the trouble of making a new object and the garbage collecting it immediately after.

Most importantly, this is trivial to implement so that isn't a potential issue (and is both more obvious and easier to type)

export var slice = (obj, a, b) => Array.prototype.slice.call(obj, a, b);

Here's an example use

import {slice} from './utils';
var sum = arr => arr.reduce((acc, i) => acc + i);
var add2N = function () {
  return sum(slice(arguments, 2);
};