Re:Deno Is Webby
by alerighi on Wednesday March 16, 2022 @07:19PM
(#30705425)
Why an array with zero element should be false? It doesn't make a lot of sense. And writing if (array.length > 0) is more explicit than writing if (array) anyway. Even in python, I prefer to be explicit and say if len(array) > 0 than to rely on implicit conversion rules.
[ Parent
| on HN ]
It would be better if Javascript had Array.empty() instead of comparing array length. It would make things even more explicit and more convenient.
Re:Deno Is Webby
by marcosdumay on Wednesday March 16, 2022 @08:10PM
(#30705875)
Personally, I don't like if even accepting things that are not boolean. But an empty array being false makes exactly as much sense as an empty string being false, and both should have always the same behavior.
If you want objects to behave like dictionaries, an empty object should also behave the same, by the way.
Re:Deno Is Webby
by heavyset_go on Wednesday March 16, 2022 @10:22PM
(#30706888)
I'd argue that `if empty_list` is already explicit in Python.