Skip to content

Instantly share code, notes, and snippets.

@estebistec
Created May 23, 2014 22:47
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save estebistec/9d7a1cc12f330140c56b to your computer and use it in GitHub Desktop.
Save estebistec/9d7a1cc12f330140c56b to your computer and use it in GitHub Desktop.
Iterating over an array with extra properties
var a = [1,2,3];
a.hasNextPage = false;
console.log(a)
// [ 1,
// 2,
// 3,
// hasNextPage: false ]
// Uh oh...
for(k in a) { console.log(k, '=>', a[k]); }
// 0 => 1
// 1 => 2
// 2 => 3
// hasNextPage => false
// Dammit...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment