Last active
March 20, 2021 12:26
-
-
Save ashwinkumar2438/b79f177d880926fbb2af936de4b8c5cf to your computer and use it in GitHub Desktop.
This file contains hidden or 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
let fakearray={ | |
[Symbol.iterator](){ | |
let x=0,done=false; | |
return { | |
next(){ | |
x++; | |
if(x>10)done=true; | |
return {value:x,done}; | |
} | |
} //@return object with next() method | |
} | |
} | |
console.log([...fakearray]); //@returns [1, 2, 3, 4, 5, 6, 7, 8, 9, 10] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment