Last active
November 28, 2018 11:33
-
-
Save IamManchanda/8b8788fbe918be0c23b919db4ab30e6d to your computer and use it in GitHub Desktop.
This file contains 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
var obj = { | |
values: [2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30, 32, 34], | |
start: 4, | |
end: 13, | |
[Symbol.iterator]() { | |
var idx = this.start; | |
var end = this.end; | |
var it = { | |
next: () => { | |
if (idx <= end) { | |
var v = this.values[idx]; | |
idx += 1; | |
return { | |
value: v, | |
done: false, | |
}; | |
} else { | |
return { | |
value: undefined, | |
done: true, | |
}; | |
} | |
} | |
}; | |
return it; | |
}, | |
}; | |
var myCustomArr = [ ...obj ]; | |
console.log(myCustomArr); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment