Skip to content

Instantly share code, notes, and snippets.

@furf
Last active August 29, 2015 14:01
Show Gist options
  • Save furf/924a226a5a0a91016e50 to your computer and use it in GitHub Desktop.
Save furf/924a226a5a0a91016e50 to your computer and use it in GitHub Desktop.
convert an array to a range, sorta.
// https://twitter.com/angustweets/status/467117418511212544
var a = [1,2,3,4,5];
a.map(Date.call, Number); // [0, 1, 2, 3, 4]
var b = []; b.length = 5;
b.map(Date.call, Number); // [undefined × 5]
var c = [,,,,,]
c.map(Date.call, Number); // [undefined × 5]
var d = [undefined, undefined, undefined, undefined, undefined];
d.map(Date.call, Number); // [0, 1, 2, 3, 4]
var e = Array(5);
e.map(Date.call, Number); // [undefined × 5]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment