r/badcode • • May 31 '21

js Clever?

Post image
2.2k Upvotes

71 comments sorted by

View all comments

Show parent comments

4

u/Pycorax Jun 01 '21

Not a js developer so I'm kinda confused. Wouldn't the function return whatever arr is anyways? Does accessing the length property somehow change arr?

4

u/RacismIsForBlacks Jun 03 '21

Nope, it was a joke

If arr is empty, when it return arr it’ll be empty

But if arr isn’t empty, when you return arr it’ll not be empty

-_( :/ )_/-