Skip to content

Instantly share code, notes, and snippets.

@ashwinkumar2438
Last active March 20, 2021 12:26
Show Gist options
  • Save ashwinkumar2438/b79f177d880926fbb2af936de4b8c5cf to your computer and use it in GitHub Desktop.
Save ashwinkumar2438/b79f177d880926fbb2af936de4b8c5cf to your computer and use it in GitHub Desktop.
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