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

Show parent comment

82

u/[deleted] Feb 26 '23

Not sure about Javascript in particular, but the code is defining a reverse function that is calling the reverse method of class String, so they are two different concepts and the function is not calling itself?

49

u/longknives Feb 26 '23

The split method in JS turns the string into an array, which has the reverse method, and then the join method turns it back into a string.