DEV Community

Discussion on: Make the global Date object iterable

Collapse
 
waju profile image
Abolarin Olanrewaju Olabode • Edited

Nice.
How about creating your own class that extends Date and then adding the Symbol.iterator to it. That way you don't change the global Date object.
If ECMA adds some kind of interation to Date in the future it won't affect your code and it makes your code more explicit.
new CustomDate()

Nice job once again

Collapse
 
aminnairi profile image
Amin

You are right. As said in the article, you can also make any classes or objects iterable. This also includes your custom date object.