Created
April 3, 2015 16:55
-
-
Save assaf/241ea1d12f975f863983 to your computer and use it in GitHub Desktop.
concat vs slice
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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