daily pastebin goal
87%
SHARE
TWEET

Untitled

a guest Nov 18th, 2018 69 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. var arr = [4,5,6,7,8,9]; for (var v of arr) { console.log( v ); } // 4 5 6 7 8 9 // define iterator that only produces values // from odd indexes arr[Symbol.iterator] = function*() { var idx = 1; do { yield this[idx]; } while ((idx += 2) < this.length); }; for (var v of arr) { console.log( v ); } // 5 7 9
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top