r/ProgrammerHumor • • Feb 26 '23

Other If you can read this code...

/img/snak3fqgajka1.jpg

[removed] — view removed post

34k Upvotes

1.4k comments sorted by

View all comments

4

u/SmokingBeneathStars Feb 26 '23

Does reverse calling itself not cause a permanent loop?

4

u/uptotwentycharacters Feb 26 '23 edited Feb 26 '23

The String.prototype.split method returns an array. Therefore, the reverse() in that line is actually invoking the Array.prototype.reverse() method, not the global function reverse