Search posts, tags, users, and pages
Kah
Software developer, runner and backyard chickens
Recently, I saw this question about how does Javascript evaluate an expression: https://twitter.com/GwagsiG/status/1303981215461105670?ref_src=twsrc%5Etfw So, why does 1 < 2 < 3 give true, but 3 > 2 > 1 give false? According to operator precedence an...
Mark
Useful warning to prevent this pitfall!
Some languages like Python understand this syntax (so that 1 < 2 < 3 is the same as 1 < 2 and 2 < 3). Many others give an error. I think Javascript's behaviour is an unfortunate mistake.
1 < 2 < 3
1 < 2 and 2 < 3
Mark
Useful warning to prevent this pitfall!
Some languages like Python understand this syntax (so that
1 < 2 < 3is the same as1 < 2 and 2 < 3). Many others give an error. I think Javascript's behaviour is an unfortunate mistake.