It doesn't. Array.prototype.map will always return a new array with the same number of elements as the original array, so calling .length on the original array would yield the same value.
Yeah basically turns the statement after into a Boolean. The bit that tickled me is that I map over the whole array just to then get the length to check if the array has a length...
2
u/MurdoMaclachlan public boolean isInt(int i) { return true; } Sep 10 '21
Image Transcription: Code
I'm a human volunteer content transcriber for Reddit and you could be too! If you'd like more information on what we do and why we do it, click here!
2
u/Host127001 Sep 10 '21
Is thus just an "is empty" check on the original array? The map shouldn't do anything, or has Javascript some weird "length" semantics?
4
u/[deleted] Sep 10 '21
[removed] — view removed comment