Skip to content

Instantly share code, notes, and snippets.

@assaf
Created April 3, 2015 16:55
Show Gist options
  • Save assaf/241ea1d12f975f863983 to your computer and use it in GitHub Desktop.
Save assaf/241ea1d12f975f863983 to your computer and use it in GitHub Desktop.
concat vs slice
const Util = require('util');
const a = [];
console.log([].concat(a).length); // => 0
console.log([].slice.call(a).length); // => 0
const Arrayish = function() {
Array.call(this);
}
Util.inherits(Arrayish, Array);
const b = new Arrayish();
console.log([].concat(b).length); // => 1
console.log([].slice.call(b).length); // => 0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment