Skip to content

Instantly share code, notes, and snippets.

@adefirmanf
Last active April 16, 2020 15:41
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 adefirmanf/19b2bc6ae4a9474598aec0be2f41fb57 to your computer and use it in GitHub Desktop.
Save adefirmanf/19b2bc6ae4a9474598aec0be2f41fb57 to your computer and use it in GitHub Desktop.
Symbol.Iterator
Number = new Proxy(Number, {
construct(target, args){
let index = 0
return {
[Symbol.iterator]() {
return this;
},
next(){
let value = args[0].toString()
if(index < value.length){
index++;
return {
value : value[index - 1]
}
}
else{
return {
a : undefined,
done : true
}
}
}
}
},
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment