Skip to content

Instantly share code, notes, and snippets.

@jialinhuang00
Created December 2, 2017 14:08
Show Gist options
  • Save jialinhuang00/e42723e02776201265e9e2cb78de3f3b to your computer and use it in GitHub Desktop.
Save jialinhuang00/e42723e02776201265e9e2cb78de3f3b to your computer and use it in GitHub Desktop.
var arr = ['a', 'b', 'c', 'd', 'e'];
var eArr = arr.entries();
console.log(eArr.next()); // { value: [ 0, 'a' ], done: false }
console.log(eArr.next().value); // [1, 'b']
// 剩下c,d,e還沒跑出來,所以...
for (let e of eArr) {
console.log(e);
}
// [ 2, 'c' ]
// [ 3, 'd' ]
// [ 4, 'e' ]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment