3 ms·
I would agree if wasn't for the fact that JS is a dynamically typed language. You can (and sometimes will) run into instances of this without noticing, because
by qayxc 5y ago
I would agree if wasn't for the fact that JS is a dynamically typed language.
You can (and sometimes will) run into instances of this without noticing, because while you won't explicitly write
true++
you might do something like
x = someFunction()
x++
not realising that someFunction() might return a boolean under some circumstances.
Anyone who worked with a sufficiently large JS codebase ran into one of these cases and got unexpected results at some point due to this.
- wruza 5y agotrue++ and x++ are syntactically different though. The latter is a post-increment of an identifier, and the former is a post-increment of a boolean literal. Different rules may apply to these cases.
- davidkunz 5y agoThis is true, one must always make sure to handle all possible return types, but that's true for all dynamic languages.